1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>db_deadlock</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="utilities.html" title="Appendix 1. Berkeley DB Command Line Utilities" /> 11 <link rel="prev" href="db_checkpoint.html" title="db_checkpoint" /> 12 <link rel="next" href="db_dump.html" title="db_dump" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">db_deadlock</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="db_checkpoint.html">Prev</a> </td> 22 <th width="60%" align="center">Appendix 1. 23 Berkeley DB Command Line Utilities 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="db_dump.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="db_deadlock"></a>db_deadlock</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">db_deadlock [-Vv] 39 [-a e | m | n | o | W | w | y] [-h home] [-L file] [-t sec.usec] </pre> 40 <p> 41 The <span class="command"><strong>db_deadlock</strong></span> utility traverses the database environment lock 42 region, and aborts a lock request each time it detects a deadlock or a 43 lock request that has timed out. By default, in the case of a 44 deadlock, a random lock request is chosen to be aborted. 45 </p> 46 <p> 47 This utility should be run as a background daemon, or the underlying 48 Berkeley DB deadlock detection interfaces should be called in some 49 other way, whenever there are multiple threads or processes accessing 50 a database and at least one of them is modifying it. 51 </p> 52 <p> 53 The options are as follows: 54 </p> 55 <div class="itemizedlist"> 56 <ul type="disc"> 57 <li> 58 <p> 59 <span class="bold"><strong>-a</strong></span> 60 </p> 61 <p> 62 When a deadlock is detected, abort the locker: 63 </p> 64 <div class="itemizedlist"> 65 <ul type="circle"> 66 <li> 67 <p> 68 <span class="bold"><strong>m</strong></span> 69 </p> 70 <p> 71 with the most locks 72 </p> 73 </li> 74 <li> 75 <p> 76 <span class="bold"><strong>n</strong></span> 77 </p> 78 <p> 79 with the fewest locks 80 </p> 81 </li> 82 <li> 83 <p> 84 <span class="bold"><strong>o</strong></span> 85 </p> 86 <p> 87 with the oldest locks 88 </p> 89 </li> 90 <li> 91 <p> 92 <span class="bold"><strong>W</strong></span> 93 </p> 94 <p> 95 with the most write locks 96 </p> 97 </li> 98 <li> 99 <p> 100 <span class="bold"><strong>w</strong></span> 101 </p> 102 <p> 103 with the fewest write locks 104 </p> 105 </li> 106 <li> 107 <p> 108 <span class="bold"><strong>y</strong></span> 109 </p> 110 <p> 111 with the youngest locks 112 </p> 113 </li> 114 <li> 115 <p> 116 <span class="bold"><strong>e</strong></span> 117 </p> 118 <p> 119 When lock or transaction timeouts have been specified, abort any lock 120 request that has timed out. Note that this option 121 does not perform the entire deadlock detection 122 algorithm, but instead only checks for timeouts. 123 </p> 124 </li> 125 </ul> 126 </div> 127 </li> 128 <li> 129 <p> 130 <span class="bold"><strong>-h</strong></span> 131 </p> 132 <p> 133 Specify a home directory for the database environment; by default, the 134 current working directory is used. 135 </p> 136 </li> 137 <li> 138 <p> 139 <span class="bold"><strong>-L</strong></span> 140 </p> 141 <p> 142 Log the execution of the <span class="command"><strong>db_deadlock</strong></span> utility to the specified file in 143 the following format, where <span class="emphasis"><em>###</em></span> is the process 144 ID, and the date is the time the utility was started. 145 </p> 146 <pre class="programlisting"> db_deadlock: ### Wed Jun 15 01:23:45 EDT 1995 </pre> 147 <p> 148 This file will be removed if the <span class="command"><strong>db_deadlock</strong></span> 149 utility exits gracefully. 150 </p> 151 </li> 152 <li> 153 <p> 154 <span class="bold"><strong>-t</strong></span> 155 </p> 156 <p> 157 Check the database environment every <span class="bold"><strong>sec</strong></span> seconds plus <span class="bold"><strong>usec</strong></span> microseconds to see if a process has been 158 forced to wait for a lock; if one has, review the database environment 159 lock structures. 160 </p> 161 </li> 162 <li> 163 <p> 164 <span class="bold"><strong>-V</strong></span> 165 </p> 166 <p> 167 Write the library version number to the standard output, and exit. 168 </p> 169 </li> 170 <li> 171 <p> 172 <span class="bold"><strong>-v</strong></span> 173 </p> 174 <p> 175 Run in verbose mode, generating messages each time the detector runs. 176 </p> 177 </li> 178 </ul> 179 </div> 180 <p> 181 If the <span class="bold"><strong>-t</strong></span> option is not specified, 182 <span class="command"><strong>db_deadlock</strong></span> will run once and exit. 183 </p> 184 <p> 185 The <span class="command"><strong>db_deadlock</strong></span> utility uses a Berkeley DB environment (as described 186 for the <span class="bold"><strong>-h</strong></span> option, the environment 187 variable <span class="bold"><strong>DB_HOME</strong></span>, or because the 188 utility was run in a directory containing a Berkeley DB environment). 189 In order to avoid environment corruption when using a Berkeley DB 190 environment, <span class="command"><strong>db_deadlock</strong></span> should always be given the chance to detach 191 from the environment and exit gracefully. To cause <span class="command"><strong>db_deadlock</strong></span> to 192 release all environment resources and exit cleanly, send it an 193 interrupt signal (SIGINT). 194 </p> 195 <p> 196 The <span class="command"><strong>db_deadlock</strong></span> utility does not attempt to create the Berkeley DB 197 shared memory regions if they do not already exist. The application 198 which creates the region should be started first, and then, once the 199 region is created, the <span class="command"><strong>db_deadlock</strong></span> utility should be started. 200 </p> 201 <p> 202 The <a class="xref" href="lockdetect.html" title="DB_ENV->lock_detect()">DB_ENV->lock_detect()</a> method 203 is the underlying method used by the <span class="command"><strong>db_deadlock</strong></span> utility. See the 204 <span class="command"><strong>db_deadlock</strong></span> utility source code for an example of using 205 <code class="methodname">DB_ENV->lock_detect()</code> in a 206 IEEE/ANSI Std 1003.1 (POSIX) environment. 207 </p> 208 <p> 209 The <span class="command"><strong>db_deadlock</strong></span> utility exits 0 on success, and >0 if an error 210 occurs. 211 </p> 212 <div class="sect2" lang="en" xml:lang="en"> 213 <div class="titlepage"> 214 <div> 215 <div> 216 <h3 class="title"><a id="id1712162"></a>Environment Variables</h3> 217 </div> 218 </div> 219 </div> 220 <div class="sect3" lang="en" xml:lang="en"> 221 <div class="titlepage"> 222 <div> 223 <div> 224 <h4 class="title"><a id="id1712694"></a>DB_HOME</h4> 225 </div> 226 </div> 227 </div> 228 <p> 229 If the <span class="bold"><strong>-h</strong></span> option is not specified and 230 the environment variable DB_HOME is set, it is used as the path of the 231 database home, as described in the 232 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method. 233 </p> 234 </div> 235 </div> 236 </div> 237 <div class="navfooter"> 238 <hr /> 239 <table width="100%" summary="Navigation footer"> 240 <tr> 241 <td width="40%" align="left"><a accesskey="p" href="db_checkpoint.html">Prev</a> </td> 242 <td width="20%" align="center"> 243 <a accesskey="u" href="utilities.html">Up</a> 244 </td> 245 <td width="40%" align="right"> <a accesskey="n" href="db_dump.html">Next</a></td> 246 </tr> 247 <tr> 248 <td width="40%" align="left" valign="top">db_checkpoint </td> 249 <td width="20%" align="center"> 250 <a accesskey="h" href="index.html">Home</a> 251 </td> 252 <td width="40%" align="right" valign="top"> db_dump</td> 253 </tr> 254 </table> 255 </div> 256 </body> 257</html> 258