Sponsored Content
Top Forums UNIX for Advanced & Expert Users Trap the EXIT_CODE from a script Post 303019169 by jim mcnamara on Sunday 24th of June 2018 12:33:24 PM
Old 06-24-2018
the V$LOCK database shows deadlocks. Most oracle "hangs" are caused by another, usually interactive process, that has a previous lock on a row. Your code performs DDL which does implicit locking (update, insert, etc.), so it is susceptible. Have your DBA clobber the offending process.

Example: We had lots of users who left for lunch in the middle of an update/insert Oracle form. Since we could not rewrite hundreds of forms to be better about transactions and locking, the DBA intervened and killed off the offending user process when a batch job got hung.

Consider DBA help.

Also oracle code example of a deadlock workaround:
Programming applications to handle deadlocks
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to use trap command in shell script

Right now I have implemented autossh between ServerA & ServerB which are sun solaris based. I have made this shell script. I am facing one problem which I am going to discuss now. The problem is when I sftp some files (suppose there is 10 files I have to transfer through sftp) from one server to... (2 Replies)
Discussion started by: girish.batra
2 Replies

2. Shell Programming and Scripting

Trap key press in a script

How can I trap a character press in the shell script. For eg:- I have a script runinng a infinite loops , I will need to quit if q is pressed. I have seen the traping the signal , but they give option only for traping the defined interrupt signals. But those does not help me here. (3 Replies)
Discussion started by: praveenbvarrier
3 Replies

3. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

4. UNIX for Advanced & Expert Users

trap ctrl c in shell script

how to trap the ctrl c in unix shell script my script is running in while loop it should not be terminate with ctrl c. if i press ctrl c while running script it shloud ignore the same. please healp.......... thanks in advance (2 Replies)
Discussion started by: arvindng
2 Replies

5. Shell Programming and Scripting

Nullify the effect of Trap command in later part of the script

Hi All, i have an issue regarding trap command. i have specified trap function in the beginning of the script to catch some signals but in the later part of the script i want to remove the effect of this. Can anybody help me out of this. for e.g. pressing Ctrl+C for the first time should... (2 Replies)
Discussion started by: vikas_kesarwani
2 Replies

6. Shell Programming and Scripting

How trap a signal in shell script?

Hi , i have a scenario where...i have to put a check where if script is executing more than 15mins i have to kill that script and n retry again 2nd time. i this case i can use background process to do it but i feel trap will be the efficent way to do so... but i dont know much about it... (1 Reply)
Discussion started by: crackthehit007
1 Replies

7. Shell Programming and Scripting

SCRIPT TO TRAP ILLEGAL COMBOS

Hello, I am trying to identify names which are "illegal" in the sense that they do not comply with the spelling norms of a culture. I have written NGrams for initial and final combos which are illegal. These are lists stored in 2 files named Initial and Final. Here are few... (2 Replies)
Discussion started by: gimley
2 Replies

8. Shell Programming and Scripting

Use of stty vs trap in script-driven login menu

My employers would like me to selectively run one of several different (already-existing) Korn Shell menu-driven scripts out of the user's .profile file, depending on some yet-to-be-specified user critieria. I've never done this kind of thing, but I have the existing scripts (among other... (5 Replies)
Discussion started by: Clovis_Sangrail
5 Replies

9. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies

10. Shell Programming and Scripting

Trap Oracle error in shell script

sqlplus -s usrname/password@dbSID <<-SQL >> logfile @create_table.sql commit; quit; SQL I am running this script to execute an sql file. I want to display the oracle error if anything found during execution of the sql file and exit from script. Please suggest How do it. (1 Reply)
Discussion started by: millan
1 Replies
Lock(3pm)						User Contributed Perl Documentation						 Lock(3pm)

NAME
DB_File::Lock - Locking with flock wrapper for DB_File SYNOPSIS
use DB_File::Lock; use Fcntl qw(:flock O_RDWR O_CREAT); $locking = "read"; $locking = "write"; $locking = { mode => "read", nonblocking => 0, lockfile_name => "/path/to/shared.lock", lockfile_mode => 0600, }; [$X =] tie %hash, 'DB_File::Lock', $filename, $flags, $mode, $DB_HASH, $locking; [$X =] tie %hash, 'DB_File::Lock', $filename, $flags, $mode, $DB_BTREE, $locking; [$X =] tie @array, 'DB_File::Lock', $filename, $flags, $mode, $DB_RECNO, $locking; # or place the DB_File arguments inside a list reference: [$X =] tie %hash, 'DB_File::Lock', [$filename, $flags, $mode, $DB_HASH], $locking; ...use the same way as DB_File for the rest of the interface... DESCRIPTION
This module provides a wrapper for the DB_File module, adding locking. When you need locking, simply use this module in place of DB_File and add an extra argument onto the tie command specifying if the file should be locked for reading or writing. The alternative is to write code like: open(LOCK, "<$db_filename.lock") or die; flock(LOCK, LOCK_SH) or die; tie(%db_hash, 'DB_File', $db_filename, O_RDONLY, 0600, $DB_HASH) or die; ... then read the database ... untie(%db_hash); close(LOCK); This module lets you write tie(%db_hash, 'DB_File::Lock', $db_filename, O_RDONLY, 0600, $DB_HASH, 'read') or die; ... then read the database ... untie(%db_hash); This is better for two reasons:(1) Less cumbersome to write.(2) A fatal exception in the code working on the database which does not lead to process termination will probably not close the lockfile and therefore cause a dropped lock. USAGE DETAILS
Tie to the database file by adding an additional locking argument to the list of arguments to be passed through to DB_File, such as: tie(%db_hash, 'DB_File::Lock', $db_filename, O_RDONLY, 0600, $DB_HASH, 'read'); or enclose the arguments for DB_File in a list reference: tie(%db_hash, 'DB_File::Lock', [$db_filename, O_RDONLY, 0600, $DB_HASH], 'read'); The filename used for the lockfile defaults to "$filename.lock" (the filename of the DB_File with ".lock" appended). Using a lockfile separate from the database file is recommended because it prevents weird interactions with the underlying database file library The additional locking argument added to the tie call can be:(1) "read" -- acquires a shared lock for reading(2) "write" -- acquires an exclusive lock for writing(3) A hash with the following keys (all optional except for the "mode"): mode the locking mode, "read" or "write". lockfile_name specifies the name of the lockfile to use. Default is "$filename.lock". This is useful for locking multiple resources with the same lockfiles. nonblocking determines if the flock call on the lockfile should block waiting for a lock, or if it should return failure if a lock can not be immediately attained. If "nonblocking" is set and a lock can not be attained, the tie command will fail. Currently, I'm not sure how to differentiate this between a failure form the DB_File layer. lockfile_mode determines the mode for the sysopen call in opening the lockfile. The default mode will be formulated to allow anyone that can read or write the DB_File permission to read and write the lockfile. (This is because some systems may require that one have write access to a file to lock it for reading, I understand.) The umask will be prevented from applying to this mode. Note: One may import the same values from DB_File::Lock as one may import from DB_File. GOOD LOCKING ETIQUETTE
To avoid locking problems, realize that it is critical that you release the lock as soon as possible. See the lock as a "hot potato", something that you must work with and get rid of as quickly as possible. See the sections of code where you have a lock as "critical" sections. Make sure that you call "untie" as soon as possible. It is often better to write: # open database file with lock # work with database # lots of processing not related to database # work with database # close database and release lock as: # open database file with lock # work with database # close database and release lock # lots of processing not related to database # open database file with lock # work with database # close database and release lock Also realize that when acquiring two locks at the same time, a deadlock situation can be caused. You can enter a deadlock situation if two processes simultaneously try to acquire locks on two separate databases. Each has locked only one of the databases, and cannot continue without locking the second. Yet this will never be freed because it is locked by the other process. If your processes all ask for their DB files in the same order, this situation cannot occur. OTHER LOCKING MODULES
There are three locking wrappers for DB_File in CPAN right now. Each one implements locking differently and has different goals in mind. It is therefore worth knowing the difference, so that you can pick the right one for your application. Here are the three locking wrappers: Tie::DB_Lock -- DB_File wrapper which creates copies of the database file for read access, so that you have kind of a multiversioning concurrent read system. However, updates are still serial. Use for databases where reads may be lengthy and consistency problems may occur. Tie::DB_LockFile -- DB_File wrapper that has the ability to lock and unlock the database while it is being used. Avoids the tie-before- flock problem by simply re-tie-ing the database when you get or drop a lock. Because of the flexibility in dropping and re-acquiring the lock in the middle of a session, this can be massaged into a system that will work with long updates and/or reads if the application follows the hints in the POD documentation. DB_File::Lock (this module) -- extremely lightweight DB_File wrapper that simply flocks a lockfile before tie-ing the database and drops the lock after the untie. Allows one to use the same lockfile for multiple databases to avoid deadlock problems, if desired. Use for databases where updates are reads are quick and simple flock locking semantics are enough. (This text duplicated in the POD documentation, by the way.) AUTHOR
David Harris <dharris@drh.net> Helpful insight from Stas Bekman <stas@stason.org> SEE ALSO
DB_File(3). perl v5.10.0 2009-07-23 Lock(3pm)
All times are GMT -4. The time now is 10:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy