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::set_lk_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_conflicts.html" title="DbEnv::set_lk_conflicts()" /> 12 <link rel="next" href="envset_lk_max_lockers.html" title="DbEnv::set_lk_max_lockers()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::set_lk_detect()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_lk_conflicts.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="envset_lk_max_lockers.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="envset_lk_detect"></a>DbEnv::set_lk_detect()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::set_lk_detect(u_int32_t detect); </pre> 42 <p> 43 Set if the deadlock detector is to be run whenever a lock conflict 44 occurs, and specify what lock request(s) should be rejected. As 45 transactions acquire locks on behalf of a single locker ID, rejecting 46 a lock request associated with a transaction normally requires the 47 transaction be aborted. 48 </p> 49 <p> 50 The database environment's deadlock detector configuration may also be 51 configured using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 52 syntax of the entry in that file is a single line with the string 53 "set_lk_detect", one or more whitespace characters, and the method 54 <span class="bold"><strong>detect</strong></span> parameter as a string; for 55 example, "set_lk_detect DB_LOCK_OLDEST". Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 56 read when the database environment is opened, it will silently 57 overrule configuration done before that time. 58 </p> 59 <p> 60 The <code class="methodname">DbEnv::set_lk_detect()</code> method configures a database environment, 61 not only operations performed using the specified <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 62 handle. 63 </p> 64 <p> 65 The <code class="methodname">DbEnv::set_lk_detect()</code> method may be called at any time during 66 the life of the application. 67 </p> 68 <p> 69 The <code class="methodname">DbEnv::set_lk_detect()</code> <span> 70 71 <span> 72 method either returns a non-zero error value or throws an 73 exception that encapsulates a non-zero error value on 74 failure, and returns 0 on success. 75 </span> 76 </span> 77 </p> 78 <div class="sect2" lang="en" xml:lang="en"> 79 <div class="titlepage"> 80 <div> 81 <div> 82 <h3 class="title"><a id="id1679688"></a>Parameters</h3> 83 </div> 84 </div> 85 </div> 86 <div class="sect3" lang="en" xml:lang="en"> 87 <div class="titlepage"> 88 <div> 89 <div> 90 <h4 class="title"><a id="id1679716"></a>detect</h4> 91 </div> 92 </div> 93 </div> 94 <p> 95 The <span class="bold"><strong>detect</strong></span> parameter configures the 96 deadlock detector. The specified value must be one of the following 97 list: 98 </p> 99 <div class="itemizedlist"> 100 <ul type="disc"> 101 <li> 102 <p><a id="set_lk_detect_DB_LOCK_DEFAULT"></a> 103 <code class="literal">DB_LOCK_DEFAULT</code> 104 </p> 105 <p> 106 Use whatever lock policy was specified when the database environment 107 was created. If no lock policy has yet been specified, set the lock 108 policy to DB_LOCK_RANDOM. 109 </p> 110 </li> 111 <li> 112 <p><a id="set_lk_detect_DB_LOCK_EXPIRE"></a> 113 <code class="literal">DB_LOCK_EXPIRE</code> 114 </p> 115 <p> 116 Reject lock requests which have timed out. No other deadlock 117 detection is performed. 118 </p> 119 </li> 120 <li> 121 <p><a id="set_lk_detect_DB_LOCK_MAXLOCKS"></a> 122 <code class="literal">DB_LOCK_MAXLOCKS</code> 123 </p> 124 <p> 125 Reject the lock request for the locker ID with the most locks. 126 </p> 127 </li> 128 <li> 129 <p><a id="set_lk_detect_DB_LOCK_MAXWRITE"></a> 130 <code class="literal">DB_LOCK_MAXWRITE</code> 131 </p> 132 <p> 133 Reject the lock request for the locker ID with the most write locks. 134 </p> 135 </li> 136 <li> 137 <p><a id="set_lk_detect_DB_LOCK_MINLOCKS"></a> 138 <code class="literal">DB_LOCK_MINLOCKS</code> 139 </p> 140 <p> 141 Reject the lock request for the locker ID with the fewest locks. 142 </p> 143 </li> 144 <li> 145 <p><a id="set_lk_detect_DB_LOCK_MINWRITE"></a> 146 <code class="literal">DB_LOCK_MINWRITE</code> 147 </p> 148 <p> 149 Reject the lock request for the locker ID with the fewest write locks. 150 </p> 151 </li> 152 <li> 153 <p><a id="set_lk_detect_DB_LOCK_OLDEST"></a> 154 <code class="literal">DB_LOCK_OLDEST</code> 155 </p> 156 <p> 157 Reject the lock request for the locker ID with the oldest lock. 158 </p> 159 </li> 160 <li> 161 <p><a id="set_lk_detect_DB_LOCK_RANDOM"></a> 162 <code class="literal">DB_LOCK_RANDOM</code> 163 </p> 164 <p> 165 Reject the lock request for a random locker ID. 166 </p> 167 </li> 168 <li> 169 <p><a id="set_lk_detect_DB_LOCK_YOUNGEST"></a> 170 <code class="literal">DB_LOCK_YOUNGEST</code> 171 </p> 172 <p> 173 Reject the lock request for the locker ID with the youngest lock. 174 </p> 175 </li> 176 </ul> 177 </div> 178 </div> 179 </div> 180 <div class="sect2" lang="en" xml:lang="en"> 181 <div class="titlepage"> 182 <div> 183 <div> 184 <h3 class="title"><a id="id1679888"></a>Errors</h3> 185 </div> 186 </div> 187 </div> 188 <p> 189 The <code class="methodname">DbEnv::set_lk_detect()</code> <span> 190 191 <span> 192 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 193 exception, encapsulating one of the following non-zero errors, or return one 194 of the following non-zero errors: 195 </span> 196 </span> 197 </p> 198 <div class="sect3" lang="en" xml:lang="en"> 199 <div class="titlepage"> 200 <div> 201 <div> 202 <h4 class="title"><a id="id1679505"></a>EINVAL</h4> 203 </div> 204 </div> 205 </div> 206 <p> 207 An invalid flag value or parameter was specified. 208 </p> 209 </div> 210 </div> 211 <div class="sect2" lang="en" xml:lang="en"> 212 <div class="titlepage"> 213 <div> 214 <div> 215 <h3 class="title"><a id="id1680147"></a>Class</h3> 216 </div> 217 </div> 218 </div> 219 <p> 220 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>, 221 <a class="link" href="lock.html" title="Chapter 7. The DbLock Handle">DbLock</a> 222 </p> 223 </div> 224 <div class="sect2" lang="en" xml:lang="en"> 225 <div class="titlepage"> 226 <div> 227 <div> 228 <h3 class="title"><a id="id1680046"></a>See Also</h3> 229 </div> 230 </div> 231 </div> 232 <p> 233 <a class="xref" href="lock.html#locklist" title="Locking Subsystem and Related Methods">Locking Subsystem and Related Methods</a> 234 </p> 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="envset_lk_conflicts.html">Prev</a> </td> 242 <td width="20%" align="center"> 243 <a accesskey="u" href="lock.html">Up</a> 244 </td> 245 <td width="40%" align="right"> <a accesskey="n" href="envset_lk_max_lockers.html">Next</a></td> 246 </tr> 247 <tr> 248 <td width="40%" align="left" valign="top">DbEnv::set_lk_conflicts() </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"> DbEnv::set_lk_max_lockers()</td> 253 </tr> 254 </table> 255 </div> 256 </body> 257</html> 258