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>DbEnv::lock_detect()</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="lock.html" title="Chapter 7. The DbLock Handle" /> 11 <link rel="prev" href="envset_lk_partitions.html" title="DbEnv::set_lk_partitions()" /> 12 <link rel="next" href="lockget.html" title="DbEnv::lock_get()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::lock_detect()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_lk_partitions.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 7. 23 The DbLock Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="lockget.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="lockdetect"></a>DbEnv::lock_detect()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::lock_detect(u_int32_t flags, u_int32_t atype, int *rejected);</pre> 42 <p> 43 The <code class="methodname">DbEnv::lock_detect()</code> method runs one iteration of the deadlock 44 detector. The deadlock detector traverses the lock table and marks one 45 of the participating lock requesters for rejection in each deadlock it 46 finds. 47 </p> 48 <p> 49 The <code class="methodname">DbEnv::lock_detect()</code> <span> 50 51 <span> 52 method either returns a non-zero error value or throws an 53 exception that encapsulates a non-zero error value on 54 failure, and returns 0 on success. 55 </span> 56 </span> 57 </p> 58 <div class="sect2" lang="en" xml:lang="en"> 59 <div class="titlepage"> 60 <div> 61 <div> 62 <h3 class="title"><a id="id1680797"></a>Parameters</h3> 63 </div> 64 </div> 65 </div> 66 <div class="sect3" lang="en" xml:lang="en"> 67 <div class="titlepage"> 68 <div> 69 <div> 70 <h4 class="title"><a id="id1680803"></a>rejected</h4> 71 </div> 72 </div> 73 </div> 74 <p> 75 If the <span class="bold"><strong>rejected</strong></span> parameter is 76 non-NULL, the memory location to which it refers will be set to the 77 number of lock requests that were rejected. 78 </p> 79 </div> 80 <div class="sect3" lang="en" xml:lang="en"> 81 <div class="titlepage"> 82 <div> 83 <div> 84 <h4 class="title"><a id="id1680904"></a>atype</h4> 85 </div> 86 </div> 87 </div> 88 <p> 89 The <span class="bold"><strong>atype</strong></span> parameter specifies which 90 lock request(s) to reject. It must be set to one of the following 91 list: 92 </p> 93 <div class="itemizedlist"> 94 <ul type="disc"> 95 <li> 96 <p><a id="detect_DB_LOCK_DEFAULT"></a> 97 <code class="literal">DB_LOCK_DEFAULT</code> 98 </p> 99 <p> 100 Use whatever lock policy was specified when the database environment 101 was created. If no lock policy has yet been specified, set the lock 102 policy to DB_LOCK_RANDOM. 103 </p> 104 </li> 105 <li> 106 <p><a id="detect_DB_LOCK_EXPIRE"></a> 107 <code class="literal">DB_LOCK_EXPIRE</code> 108 </p> 109 <p> 110 Reject lock requests which have timed out. No other deadlock 111 detection is performed. 112 </p> 113 </li> 114 <li> 115 <p><a id="detect_DB_LOCK_MAXLOCKS"></a> 116 <code class="literal">DB_LOCK_MAXLOCKS</code> 117 </p> 118 <p> 119 Reject the lock request for the locker ID with the most locks. 120 </p> 121 </li> 122 <li> 123 <p><a id="detect_DB_LOCK_MAXWRITE"></a> 124 <code class="literal">DB_LOCK_MAXWRITE</code> 125 </p> 126 <p> 127 Reject the lock request for the locker ID with the most write locks. 128 </p> 129 </li> 130 <li> 131 <p><a id="detect_DB_LOCK_MINLOCKS"></a> 132 <code class="literal">DB_LOCK_MINLOCKS</code> 133 </p> 134 <p> 135 Reject the lock request for the locker ID with the fewest locks. 136 </p> 137 </li> 138 <li> 139 <p><a id="detect_DB_LOCK_MINWRITE"></a> 140 <code class="literal">DB_LOCK_MINWRITE</code> 141 </p> 142 <p> 143 Reject the lock request for the locker ID with the fewest write locks. 144 </p> 145 </li> 146 <li> 147 <p><a id="detect_DB_LOCK_OLDEST"></a> 148 <code class="literal">DB_LOCK_OLDEST</code> 149 </p> 150 <p> 151 Reject the lock request for the locker ID with the oldest lock. 152 </p> 153 </li> 154 <li> 155 <p><a id="detect_DB_LOCK_RANDOM"></a> 156 <code class="literal">DB_LOCK_RANDOM</code> 157 </p> 158 <p> 159 Reject the lock request for a random locker ID. 160 </p> 161 </li> 162 <li> 163 <p><a id="detect_DB_LOCK_YOUNGEST"></a> 164 <code class="literal">DB_LOCK_YOUNGEST</code> 165 </p> 166 <p> 167 Reject the lock request for the locker ID with the youngest lock. 168 </p> 169 </li> 170 </ul> 171 </div> 172 </div> 173 <div class="sect3" lang="en" xml:lang="en"> 174 <div class="titlepage"> 175 <div> 176 <div> 177 <h4 class="title"><a id="id1681357"></a>flags</h4> 178 </div> 179 </div> 180 </div> 181 <p> 182 The <span class="bold"><strong>flags</strong></span> parameter is currently 183 unused, and must be set to 0. 184 </p> 185 </div> 186 </div> 187 <div class="sect2" lang="en" xml:lang="en"> 188 <div class="titlepage"> 189 <div> 190 <div> 191 <h3 class="title"><a id="id1681098"></a>Errors</h3> 192 </div> 193 </div> 194 </div> 195 <p> 196 The <code class="methodname">DbEnv::lock_detect()</code> <span> 197 198 <span> 199 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 200 exception, encapsulating one of the following non-zero errors, or return one 201 of the following non-zero errors: 202 </span> 203 </span> 204 </p> 205 <div class="sect3" lang="en" xml:lang="en"> 206 <div class="titlepage"> 207 <div> 208 <div> 209 <h4 class="title"><a id="id1681274"></a>EINVAL</h4> 210 </div> 211 </div> 212 </div> 213 <p> 214 An invalid flag value or parameter was specified. 215 </p> 216 </div> 217 </div> 218 <div class="sect2" lang="en" xml:lang="en"> 219 <div class="titlepage"> 220 <div> 221 <div> 222 <h3 class="title"><a id="id1681361"></a>Class</h3> 223 </div> 224 </div> 225 </div> 226 <p> 227 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>, <a class="link" href="lock.html" title="Chapter 7. The DbLock Handle">DbLock</a> 228 </p> 229 </div> 230 <div class="sect2" lang="en" xml:lang="en"> 231 <div class="titlepage"> 232 <div> 233 <div> 234 <h3 class="title"><a id="id1680801"></a>See Also</h3> 235 </div> 236 </div> 237 </div> 238 <p> 239 <a class="xref" href="lock.html#locklist" title="Locking Subsystem and Related Methods">Locking Subsystem and Related Methods</a> 240 </p> 241 </div> 242 </div> 243 <div class="navfooter"> 244 <hr /> 245 <table width="100%" summary="Navigation footer"> 246 <tr> 247 <td width="40%" align="left"><a accesskey="p" href="envset_lk_partitions.html">Prev</a> </td> 248 <td width="20%" align="center"> 249 <a accesskey="u" href="lock.html">Up</a> 250 </td> 251 <td width="40%" align="right"> <a accesskey="n" href="lockget.html">Next</a></td> 252 </tr> 253 <tr> 254 <td width="40%" align="left" valign="top">DbEnv::set_lk_partitions() </td> 255 <td width="20%" align="center"> 256 <a accesskey="h" href="index.html">Home</a> 257 </td> 258 <td width="40%" align="right" valign="top"> DbEnv::lock_get()</td> 259 </tr> 260 </table> 261 </div> 262 </body> 263</html> 264