| 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::failchk()</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="enverr.html" title="DbEnv::err()" /> |
| 12 | <link rel="next" href="envfileid_reset.html" title="DbEnv::fileid_reset()" /> |
| 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::failchk()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="enverr.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="envfileid_reset.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="envfailchk"></a>DbEnv::failchk()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbEnv::failchk(u_int32_t flags);</pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DbEnv::failchk()</code> method checks for threads of control (either a |
| 47 | true thread or a process) that have exited while manipulating Berkeley |
| 48 | DB library data structures, while holding a logical database lock, or |
| 49 | with an unresolved transaction (that is, a transaction that was never |
| 50 | aborted or committed). For more information, see |
| 51 | <a href="../../programmer_reference/cam_app.html" class="olink">Architecting Data Store and |
| 52 | Concurrent Data Store applications</a>, and |
| 53 | <a href="../../programmer_reference/transapp_app.html" class="olink">Architecting Transactional |
| 54 | Data Store applications</a>, both in the |
| 55 | <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>. |
| 56 | </p> |
| 57 | <p> |
| 58 | The <code class="methodname">DbEnv::failchk()</code> method is |
| 59 | used in conjunction with the |
| 60 | <a class="xref" href="envset_thread_count.html" title="DbEnv::set_thread_count()">DbEnv::set_thread_count()</a>, |
| 61 | <a class="xref" href="envset_isalive.html" title="DbEnv::set_isalive()">DbEnv::set_isalive()</a> and |
| 62 | <a class="xref" href="envset_thread_id.html" title="DbEnv::set_thread_id()">DbEnv::set_thread_id()</a> |
| 63 | methods. Before calling the <code class="methodname">failchk()</code>method, applications must: |
| 64 | </p> |
| 65 | <div class="orderedlist"> |
| 66 | <ol type="1"> |
| 67 | <li> |
| 68 | <p> |
| 69 | Configure their database using the |
| 70 | <a class="xref" href="envset_thread_count.html" title="DbEnv::set_thread_count()">DbEnv::set_thread_count()</a> |
| 71 | method. |
| 72 | </p> |
| 73 | </li> |
| 74 | <li> |
| 75 | <p> |
| 76 | Establish an <code class="literal">is_alive()</code> function and |
| 77 | invoke |
| 78 | <a class="xref" href="envset_isalive.html" title="DbEnv::set_isalive()">DbEnv::set_isalive()</a> |
| 79 | with that function as the <code class="literal">is_alive</code> parameter. |
| 80 | </p> |
| 81 | </li> |
| 82 | <li> |
| 83 | <p> |
| 84 | Establish a <code class="literal">thread_id</code> function and |
| 85 | invoke |
| 86 | <a class="xref" href="envset_thread_id.html" title="DbEnv::set_thread_id()">DbEnv::set_thread_id()</a> |
| 87 | with that function as the <code class="literal">thread_id</code> |
| 88 | parameter. |
| 89 | </p> |
| 90 | </li> |
| 91 | </ol> |
| 92 | </div> |
| 93 | <p> |
| 94 | If any of these methods are omitted, a program may be unable to |
| 95 | allocate a thread control block. This is true of the standalone |
| 96 | Berkeley DB utility programs. To avoid problems when using the |
| 97 | standalone Berkeley DB utility programs with environments |
| 98 | configured for failure checking, incorporate the utility's |
| 99 | functionality directly in the application, or call the |
| 100 | <code class="methodname">DbEnv::failchk()</code> method along with its |
| 101 | associated methods before running the utility. |
| 102 | </p> |
| 103 | <p> |
| 104 | If <code class="methodname">DbEnv::failchk()</code> determines a thread of control exited while |
| 105 | holding database read locks, it will release those locks. If |
| 106 | <code class="methodname">DbEnv::failchk()</code> determines a thread of control exited with an |
| 107 | unresolved transaction, the transaction will be aborted. In either of |
| 108 | these cases, <code class="methodname">DbEnv::failchk()</code> will return 0 and the application may |
| 109 | continue to use the database environment. |
| 110 | </p> |
| 111 | <p> |
| 112 | In either of these cases, the <code class="methodname">DbEnv::failchk()</code> method will also |
| 113 | report the process and thread IDs associated with any released locks |
| 114 | or aborted transactions. The information is printed to a specified |
| 115 | output channel (see the |
| 116 | <a class="xref" href="envset_msgfile.html" title="DbEnv::set_msgfile()">DbEnv::set_msgfile()</a> |
| 117 | method for more information), or passed to an application callback |
| 118 | function (see the |
| 119 | <a class="xref" href="envset_msgcall.html" title="DbEnv::set_msgcall()">DbEnv::set_msgcall()</a> |
| 120 | method for more information). |
| 121 | </p> |
| 122 | <p> |
| 123 | If <code class="methodname">DbEnv::failchk()</code> determines a thread of control has exited such |
| 124 | that database environment recovery is required, it will return |
| 125 | <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_RUNRECOVERY" class="olink">DB_RUNRECOVERY</a>. |
| 126 | In this case, the application should not continue to use the database |
| 127 | environment. For a further description as to the actions the |
| 128 | application should take when this failure occurs, see |
| 129 | <a href="../../programmer_reference/cam_fail.html" class="olink">Handling failure in Data Store and |
| 130 | Concurrent Data Store applications</a>, and |
| 131 | <a href="../../programmer_reference/transapp_fail.html" class="olink">Handling failure in Transactional Data |
| 132 | Store applications</a>, both in the |
| 133 | <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>. |
| 134 | </p> |
| 135 | <p> |
| 136 | In multiprocess applications, it is recommended that the <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle |
| 137 | used to invoke the <code class="methodname">DbEnv::failchk()</code> method not be shared and therefore |
| 138 | not <span class="emphasis"><em>free-threaded</em></span>. |
| 139 | </p> |
| 140 | <p> |
| 141 | The <code class="methodname">DbEnv::failchk()</code> method may not be called by the |
| 142 | application before the <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> |
| 143 | method is called. |
| 144 | </p> |
| 145 | <p> |
| 146 | The <code class="methodname">DbEnv::failchk()</code> <span> |
| 147 | |
| 148 | <span> |
| 149 | method either returns a non-zero error value or throws an |
| 150 | exception that encapsulates a non-zero error value on |
| 151 | failure, and returns 0 on success. |
| 152 | </span> |
| 153 | </span> |
| 154 | </p> |
| 155 | <div class="sect2" lang="en" xml:lang="en"> |
| 156 | <div class="titlepage"> |
| 157 | <div> |
| 158 | <div> |
| 159 | <h3 class="title"><a id="idp6751008"></a>Parameters</h3> |
| 160 | </div> |
| 161 | </div> |
| 162 | </div> |
| 163 | <div class="sect3" lang="en" xml:lang="en"> |
| 164 | <div class="titlepage"> |
| 165 | <div> |
| 166 | <div> |
| 167 | <h4 class="title"><a id="idp6750360"></a>flags</h4> |
| 168 | </div> |
| 169 | </div> |
| 170 | </div> |
| 171 | <p> |
| 172 | The <span class="bold"><strong>flags</strong></span> parameter is currently |
| 173 | unused, and must be set to 0. |
| 174 | </p> |
| 175 | </div> |
| 176 | </div> |
| 177 | <div class="sect2" lang="en" xml:lang="en"> |
| 178 | <div class="titlepage"> |
| 179 | <div> |
| 180 | <div> |
| 181 | <h3 class="title"><a id="idp6755536"></a>Errors</h3> |
| 182 | </div> |
| 183 | </div> |
| 184 | </div> |
| 185 | <p> |
| 186 | The <code class="methodname">DbEnv::failchk()</code> <span> |
| 187 | |
| 188 | <span> |
| 189 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 190 | exception, encapsulating one of the following non-zero errors, or return one |
| 191 | of the following non-zero errors: |
| 192 | </span> |
| 193 | </span> |
| 194 | </p> |
| 195 | <div class="sect3" lang="en" xml:lang="en"> |
| 196 | <div class="titlepage"> |
| 197 | <div> |
| 198 | <div> |
| 199 | <h4 class="title"><a id="idp6768072"></a>EINVAL</h4> |
| 200 | </div> |
| 201 | </div> |
| 202 | </div> |
| 203 | <p> |
| 204 | An invalid flag value or parameter was specified. |
| 205 | </p> |
| 206 | </div> |
| 207 | </div> |
| 208 | <div class="sect2" lang="en" xml:lang="en"> |
| 209 | <div class="titlepage"> |
| 210 | <div> |
| 211 | <div> |
| 212 | <h3 class="title"><a id="idp6766776"></a>Class</h3> |
| 213 | </div> |
| 214 | </div> |
| 215 | </div> |
| 216 | <p> |
| 217 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 218 | </p> |
| 219 | </div> |
| 220 | <div class="sect2" lang="en" xml:lang="en"> |
| 221 | <div class="titlepage"> |
| 222 | <div> |
| 223 | <div> |
| 224 | <h3 class="title"><a id="idp6769400"></a>See Also</h3> |
| 225 | </div> |
| 226 | </div> |
| 227 | </div> |
| 228 | <p> |
| 229 | <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> |
| 230 | </p> |
| 231 | </div> |
| 232 | </div> |
| 233 | <div class="navfooter"> |
| 234 | <hr /> |
| 235 | <table width="100%" summary="Navigation footer"> |
| 236 | <tr> |
| 237 | <td width="40%" align="left"><a accesskey="p" href="enverr.html">Prev</a> </td> |
| 238 | <td width="20%" align="center"> |
| 239 | <a accesskey="u" href="env.html">Up</a> |
| 240 | </td> |
| 241 | <td width="40%" align="right"> <a accesskey="n" href="envfileid_reset.html">Next</a></td> |
| 242 | </tr> |
| 243 | <tr> |
| 244 | <td width="40%" align="left" valign="top">DbEnv::err() </td> |
| 245 | <td width="20%" align="center"> |
| 246 | <a accesskey="h" href="index.html">Home</a> |
| 247 | </td> |
| 248 | <td width="40%" align="right" valign="top"> DbEnv::fileid_reset()</td> |
| 249 | </tr> |
| 250 | </table> |
| 251 | </div> |
| 252 | </body> |
| 253 | </html> |