| 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_timeout()</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="env.html" title="Chapter 5. The DbEnv Handle" /> |
| 11 | <link rel="prev" href="envset_thread_id_string.html" title="DbEnv::set_thread_id_string()" /> |
| 12 | <link rel="next" href="envset_tmp_dir.html" title="DbEnv::set_tmp_dir()" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">DbEnv::set_timeout()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="envset_thread_id_string.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 5. |
| 26 | The DbEnv Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="envset_tmp_dir.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="envset_timeout"></a>DbEnv::set_timeout()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbEnv::set_timeout(db_timeout_t timeout, u_int32_t flags); </pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DbEnv::set_timeout()</code> method sets timeout values for locks or |
| 47 | transactions in the database environment, and the wait time for a process to |
| 48 | exit the environment when |
| 49 | <a class="link" href="envopen.html#envopen_DB_REGISTER">DB_REGISTER</a> |
| 50 | recovery is needed. |
| 51 | </p> |
| 52 | <p> |
| 53 | DB_SET_LOCK_TIMEOUT and DB_SET_TXN_TIMEOUT timeouts are checked whenever a |
| 54 | thread of control blocks on a lock or when deadlock detection is performed. |
| 55 | In the case of DB_SET_LOCK_TIMEOUT, the lock is one requested explicitly |
| 56 | through the Lock subsystem interfaces. In the case of DB_SET_TXN_TIMEOUT, the |
| 57 | lock is one requested on behalf of a transaction. In either case, it |
| 58 | may be a lock requested by the database access methods underlying the |
| 59 | application. These timeouts are only checked when the lock request |
| 60 | first blocks or when deadlock detection is performed, the accuracy of |
| 61 | the timeout depends on how often deadlock detection is performed. |
| 62 | </p> |
| 63 | <p> |
| 64 | Lock and transaction timeout values specified for the database environment may |
| 65 | be overridden on a per-lock or per-transaction basis. See |
| 66 | <a class="xref" href="lockvec.html" title="DbEnv::lock_vec()">DbEnv::lock_vec()</a> and |
| 67 | <a class="xref" href="txnset_timeout.html" title="DbTxn::set_timeout()">DbTxn::set_timeout()</a> for |
| 68 | more information. |
| 69 | </p> |
| 70 | <p> |
| 71 | The <code class="methodname">DbEnv::set_timeout()</code> method may not be used in a database |
| 72 | environment without a locking subsystem. |
| 73 | </p> |
| 74 | <p> |
| 75 | The <code class="methodname">DbEnv::set_timeout()</code> method may be called at any time during the |
| 76 | life of the application. |
| 77 | </p> |
| 78 | <p> |
| 79 | The <code class="methodname">DbEnv::set_timeout()</code> <span> |
| 80 | |
| 81 | <span> |
| 82 | method either returns a non-zero error value or throws an |
| 83 | exception that encapsulates a non-zero error value on |
| 84 | failure, and returns 0 on success. |
| 85 | </span> |
| 86 | </span> |
| 87 | </p> |
| 88 | <div class="sect2" lang="en" xml:lang="en"> |
| 89 | <div class="titlepage"> |
| 90 | <div> |
| 91 | <div> |
| 92 | <h3 class="title"><a id="idp7663400"></a>Parameters</h3> |
| 93 | </div> |
| 94 | </div> |
| 95 | </div> |
| 96 | <div class="sect3" lang="en" xml:lang="en"> |
| 97 | <div class="titlepage"> |
| 98 | <div> |
| 99 | <div> |
| 100 | <h4 class="title"><a id="idp7660432"></a>timeout</h4> |
| 101 | </div> |
| 102 | </div> |
| 103 | </div> |
| 104 | <p> |
| 105 | The <span class="bold"><strong>timeout</strong></span> parameter is the timeout value. It must |
| 106 | be specified as an unsigned 32-bit number of microseconds, limiting the maximum |
| 107 | timeout to roughly 71 minutes. |
| 108 | </p> |
| 109 | </div> |
| 110 | <div class="sect3" lang="en" xml:lang="en"> |
| 111 | <div class="titlepage"> |
| 112 | <div> |
| 113 | <div> |
| 114 | <h4 class="title"><a id="idp7661768"></a>flags</h4> |
| 115 | </div> |
| 116 | </div> |
| 117 | </div> |
| 118 | <p> |
| 119 | The <span class="bold"><strong>flags</strong></span> parameter must be set to |
| 120 | one of the following values: |
| 121 | </p> |
| 122 | <div class="itemizedlist"> |
| 123 | <ul type="disc"> |
| 124 | <li> |
| 125 | <p><a id="set_timeout_DB_SET_LOCK_TIMEOUT"></a> |
| 126 | <code class="literal">DB_SET_LOCK_TIMEOUT</code> |
| 127 | </p> |
| 128 | <p> |
| 129 | Set the timeout value for locks in this database environment. |
| 130 | </p> |
| 131 | <p> |
| 132 | The database environment's lock timeout value may also |
| 133 | be configured using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> |
| 134 | file. The syntax of the entry in that file is a |
| 135 | single line with the string "set_lock_timeout", one or |
| 136 | more whitespace characters, and the lock timeout |
| 137 | value. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is read when the |
| 138 | database environment is opened, it will silently |
| 139 | overrule configuration done before that time. |
| 140 | </p> |
| 141 | <p> |
| 142 | This flag configures a database environment, not only operations |
| 143 | performed using the specified |
| 144 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. |
| 145 | </p> |
| 146 | </li> |
| 147 | <li> |
| 148 | <p><a id="set_timeout_DB_SET_REG_TIMEOUT"></a> |
| 149 | <code class="literal">DB_SET_REG_TIMEOUT</code> |
| 150 | </p> |
| 151 | <p> |
| 152 | Set the timeout value on how long to wait for processes to exit the environment |
| 153 | before recovery is started when the |
| 154 | <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method was called with the |
| 155 | <a class="link" href="envopen.html#envopen_DB_REGISTER">DB_REGISTER</a> |
| 156 | flag and recovery must be performed. |
| 157 | </p> |
| 158 | <p> |
| 159 | This wait timeout value may also be configured using |
| 160 | the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The syntax of the |
| 161 | entry in that file is a single line with the string |
| 162 | "set_reg_timeout", one or more whitespace characters, |
| 163 | and the wait timeout value. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> |
| 164 | file is read when the database environment is opened, |
| 165 | it will silently overrule configuration done before |
| 166 | that time. |
| 167 | </p> |
| 168 | <p> |
| 169 | This flag configures operations performed using the specified |
| 170 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. |
| 171 | </p> |
| 172 | </li> |
| 173 | <li> |
| 174 | <p><a id="set_timeout_DB_SET_TXN_TIMEOUT"></a> |
| 175 | <code class="literal">DB_SET_TXN_TIMEOUT</code> |
| 176 | </p> |
| 177 | <p> |
| 178 | Set the timeout value for transactions in this database environment. |
| 179 | </p> |
| 180 | <p> |
| 181 | The database environment's transaction timeout value |
| 182 | may also be configured using the environment's |
| 183 | <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The syntax of the entry in that |
| 184 | file is a single line with the string |
| 185 | "set_txn_timeout", one or more whitespace characters, |
| 186 | and the transaction timeout value. Because the |
| 187 | <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is read when the database environment |
| 188 | is opened, it will silently overrule configuration |
| 189 | done before that time. |
| 190 | </p> |
| 191 | <p> |
| 192 | This flag configures a database environment, not only |
| 193 | operations performed using the specified |
| 194 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. |
| 195 | </p> |
| 196 | </li> |
| 197 | </ul> |
| 198 | </div> |
| 199 | </div> |
| 200 | </div> |
| 201 | <div class="sect2" lang="en" xml:lang="en"> |
| 202 | <div class="titlepage"> |
| 203 | <div> |
| 204 | <div> |
| 205 | <h3 class="title"><a id="idp7678664"></a>Errors</h3> |
| 206 | </div> |
| 207 | </div> |
| 208 | </div> |
| 209 | <p> |
| 210 | The <code class="methodname">DbEnv::set_timeout()</code> <span> |
| 211 | |
| 212 | <span> |
| 213 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 214 | exception, encapsulating one of the following non-zero errors, or return one |
| 215 | of the following non-zero errors: |
| 216 | </span> |
| 217 | </span> |
| 218 | </p> |
| 219 | <div class="sect3" lang="en" xml:lang="en"> |
| 220 | <div class="titlepage"> |
| 221 | <div> |
| 222 | <div> |
| 223 | <h4 class="title"><a id="idp7672304"></a>EINVAL</h4> |
| 224 | </div> |
| 225 | </div> |
| 226 | </div> |
| 227 | <p> |
| 228 | An invalid flag value or parameter was specified. |
| 229 | </p> |
| 230 | </div> |
| 231 | </div> |
| 232 | <div class="sect2" lang="en" xml:lang="en"> |
| 233 | <div class="titlepage"> |
| 234 | <div> |
| 235 | <div> |
| 236 | <h3 class="title"><a id="idp7685064"></a>Class</h3> |
| 237 | </div> |
| 238 | </div> |
| 239 | </div> |
| 240 | <p> |
| 241 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 242 | </p> |
| 243 | </div> |
| 244 | <div class="sect2" lang="en" xml:lang="en"> |
| 245 | <div class="titlepage"> |
| 246 | <div> |
| 247 | <div> |
| 248 | <h3 class="title"><a id="idp7681792"></a>See Also</h3> |
| 249 | </div> |
| 250 | </div> |
| 251 | </div> |
| 252 | <p> |
| 253 | <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> |
| 254 | </p> |
| 255 | </div> |
| 256 | </div> |
| 257 | <div class="navfooter"> |
| 258 | <hr /> |
| 259 | <table width="100%" summary="Navigation footer"> |
| 260 | <tr> |
| 261 | <td width="40%" align="left"><a accesskey="p" href="envset_thread_id_string.html">Prev</a> </td> |
| 262 | <td width="20%" align="center"> |
| 263 | <a accesskey="u" href="env.html">Up</a> |
| 264 | </td> |
| 265 | <td width="40%" align="right"> <a accesskey="n" href="envset_tmp_dir.html">Next</a></td> |
| 266 | </tr> |
| 267 | <tr> |
| 268 | <td width="40%" align="left" valign="top">DbEnv::set_thread_id_string() </td> |
| 269 | <td width="20%" align="center"> |
| 270 | <a accesskey="h" href="index.html">Home</a> |
| 271 | </td> |
| 272 | <td width="40%" align="right" valign="top"> DbEnv::set_tmp_dir()</td> |
| 273 | </tr> |
| 274 | </table> |
| 275 | </div> |
| 276 | </body> |
| 277 | </html> |