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 <span class="command"><strong>db_deadlock</strong></span> utility exits 0 on success, and >0 if an error 203 occurs. 204 </p> 205 <div class="sect2" lang="en" xml:lang="en"> 206 <div class="titlepage"> 207 <div> 208 <div> 209 <h3 class="title"><a id="id1717010"></a>Environment Variables</h3> 210 </div> 211 </div> 212 </div> 213 <div class="sect3" lang="en" xml:lang="en"> 214 <div class="titlepage"> 215 <div> 216 <div> 217 <h4 class="title"><a id="id1717085"></a>DB_HOME</h4> 218 </div> 219 </div> 220 </div> 221 <p> 222 If the <span class="bold"><strong>-h</strong></span> option is not specified and 223 the environment variable DB_HOME is set, it is used as the path of the 224 database home, as described in the 225 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method. 226 </p> 227 </div> 228 </div> 229 </div> 230 <div class="navfooter"> 231 <hr /> 232 <table width="100%" summary="Navigation footer"> 233 <tr> 234 <td width="40%" align="left"><a accesskey="p" href="db_checkpoint.html">Prev</a> </td> 235 <td width="20%" align="center"> 236 <a accesskey="u" href="utilities.html">Up</a> 237 </td> 238 <td width="40%" align="right"> <a accesskey="n" href="db_dump.html">Next</a></td> 239 </tr> 240 <tr> 241 <td width="40%" align="left" valign="top">db_checkpoint </td> 242 <td width="20%" align="center"> 243 <a accesskey="h" href="index.html">Home</a> 244 </td> 245 <td width="40%" align="right" valign="top"> db_dump</td> 246 </tr> 247 </table> 248 </div> 249 </body> 250</html> 251