1<!--$Id: db_deadlock.so,v 10.33 2007/10/26 15:02:55 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: db_deadlock</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>db_deadlock</b> 14</td> 15</tr></table> 16<hr size=1 noshade> 17<tt> 18<b><pre>db_deadlock [<b>-Vv</b>] 19 [<b>-a e | m | n | o | W | w | y</b>] [<b>-h home</b>] [<b>-L file</b>] [<b>-t sec.usec</b>]</pre></b> 20<b>Description</b> 21<a name="2"><!--meow--></a> 22<p>The db_deadlock utility traverses the database environment lock 23region, and aborts a lock request each time it detects a deadlock or a 24lock request that has timed out. By default, in the case of a deadlock, 25a random lock request is chosen to be aborted.</p> 26<p>This utility should be run as a background daemon, or the underlying 27Berkeley DB deadlock detection interfaces should be called in some other way, 28whenever there are multiple threads or processes accessing a database 29and at least one of them is modifying it.</p> 30<p>The options are as follows:</p> 31<br> 32<b>-a</b><ul compact><li>When a deadlock is detected, abort the locker: 33<br> 34<b>m</b><ul compact><li>with the most locks</ul> 35<b>n</b><ul compact><li>with the fewest locks</ul> 36<b>o</b><ul compact><li>with the oldest lock</ul> 37<b>W</b><ul compact><li>with the most write locks</ul> 38<b>w</b><ul compact><li>with the fewest write locks</ul> 39<b>y</b><ul compact><li>with the youngest lock</ul> 40<br></ul> 41<p>When lock or transaction timeouts have been specified: 42<br> 43<b>e</b><ul compact><li>abort any lock request that has timed out</ul> 44<br></p> 45<b>-h</b><ul compact><li>Specify a home directory for the database environment; by 46default, the current working directory is used.</ul> 47<b>-L</b><ul compact><li>Log the execution of the db_deadlock utility to the specified file in the 48following format, where <i>###</i> is the process ID, and the date 49is the time the utility was started. 50<blockquote><pre>db_deadlock: ### Wed Jun 15 01:23:45 EDT 1995</pre></blockquote> 51This file will be removed if the db_deadlock utility exits gracefully.</ul> 52<b>-t</b><ul compact><li>Check the database environment every <b>sec</b> seconds plus 53<b>usec</b> microseconds to see if a process has been forced to wait 54for a lock; if one has, review the database environment lock 55structures.</ul> 56<b>-V</b><ul compact><li>Write the library version number to the standard output, and exit.</ul> 57<b>-v</b><ul compact><li>Run in verbose mode, generating messages each time the detector runs.</ul> 58<br> 59<p>If the <b>-t</b> option is not specified, db_deadlock will 60run once and exit.</p> 61<p>The db_deadlock utility uses a Berkeley DB environment (as described for the 62<b>-h</b> option, the environment variable <b>DB_HOME</b>, or 63because the utility was run in a directory containing a Berkeley DB 64environment). In order to avoid environment corruption when using a 65Berkeley DB environment, db_deadlock should always be given the chance to 66detach from the environment and exit gracefully. To cause db_deadlock 67to release all environment resources and exit cleanly, send it an 68interrupt signal (SIGINT).</p> 69<p>The db_deadlock utility does not attempt to create the Berkeley DB 70shared memory regions if they do not already exist. The application 71which creates the region should be started first, and then, once the 72region is created, the db_deadlock utility should be started.</p> 73<p>The <a href="../api_c/lock_detect.html">DB_ENV->lock_detect</a> method is the underlying method used by the db_deadlock utility. 74See the db_deadlock utility source code for an example of using <a href="../api_c/lock_detect.html">DB_ENV->lock_detect</a> 75in a IEEE/ANSI Std 1003.1 (POSIX) environment.</p> 76<p>The db_deadlock utility exits 0 on success, and >0 if an error occurs.</p> 77<br><b>Environment Variables</b> 78<br> 79<b>DB_HOME</b><ul compact><li>If the <b>-h</b> option is not specified and the environment variable 80DB_HOME is set, it is used as the path of the database home, as described 81in <a href="../api_c/env_open.html">DB_ENV->open</a>.</ul> 82<br> 83</tt> 84<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 85</body> 86</html> 87