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_ENV->txn_recover()</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="txn.html" title="Chapter 12. The DB_TXN Handle" /> 11 <link rel="prev" href="txnprepare.html" title="DB_TXN->prepare()" /> 12 <link rel="next" href="txnset_name.html" title="DB_TXN->set_name()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->txn_recover()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="txnprepare.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 12. 23 The DB_TXN Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="txnset_name.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="txnrecover"></a>DB_ENV->txn_recover()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->txn_recover(DB_ENV *dbenv, DB_PREPLIST preplist[], 42 long count, long *retp, u_int32_t flags); </pre> 43 <p> 44 Database environment recovery restores transactions that were 45 prepared, but not yet resolved at the time of the system shut down or 46 crash, to their state prior to the shut down or crash, including any 47 locks previously held. The <code class="methodname">DB_ENV->txn_recover()</code> method returns a 48 list of those prepared transactions. 49 </p> 50 <p> 51 The <code class="methodname">DB_ENV->txn_recover()</code> method should only be called after the 52 environment has been recovered. 53 </p> 54 <p> 55 Multiple threads of control may call <code class="methodname">DB_ENV->txn_recover()</code>, but only 56 one thread of control may resolve each returned transaction, that is, 57 only one thread of control may call <a class="xref" href="txncommit.html" title="DB_TXN->commit()">DB_TXN->commit()</a> 58 or <a class="xref" href="txnabort.html" title="DB_TXN->abort()">DB_TXN->abort()</a> on each 59 returned transaction. Callers of <code class="methodname">DB_ENV->txn_recover()</code> must call 60 <a class="xref" href="txndiscard.html" title="DB_TXN->discard()">DB_TXN->discard()</a> to 61 discard each transaction they do not resolve. 62 </p> 63 <p> 64 On return from <code class="methodname">DB_ENV->txn_recover()</code>, the <span class="bold"><strong>preplist</strong></span> parameter will be filled in with a list of transactions 65 that must be resolved by the application (committed, aborted or discarded). The <span class="bold"><strong>preplist</strong></span> parameter is a structure of type 66 <code class="literal">DB_PREPLIST</code>; the following <code class="literal">DB_PREPLIST</code> fields will be 67 filled in: 68 </p> 69 <div class="itemizedlist"> 70 <ul type="disc"> 71 <li> 72 <p> 73 <span class="bold"><strong>DB_TXN * txn;</strong></span> 74 </p> 75 <p> 76 The transaction handle for the transaction. 77 </p> 78 </li> 79 <li> 80 <p> 81 <span class="bold"><strong>u_int8_t gid[DB_XIDDATASIZE];</strong></span> 82 </p> 83 <p> 84 The global transaction ID for the transaction. The global transaction 85 ID is the one specified when the transaction was prepared. The 86 application is responsible for ensuring uniqueness among global 87 transaction IDs. 88 </p> 89 </li> 90 </ul> 91 </div> 92 <p> 93 The <code class="methodname">DB_ENV->txn_recover()</code> <span> 94 <span> 95 method returns a non-zero error value on failure and 0 on success. 96 </span> 97 98 </span> 99 </p> 100 <div class="sect2" lang="en" xml:lang="en"> 101 <div class="titlepage"> 102 <div> 103 <div> 104 <h3 class="title"><a id="id1709562"></a>Parameters</h3> 105 </div> 106 </div> 107 </div> 108 <div class="sect3" lang="en" xml:lang="en"> 109 <div class="titlepage"> 110 <div> 111 <div> 112 <h4 class="title"><a id="id1709950"></a>count</h4> 113 </div> 114 </div> 115 </div> 116 <p> 117 The <span class="bold"><strong>count</strong></span> parameter specifies the 118 number of available entries in the passed-in <span class="bold"><strong>preplist</strong></span> array. The <span class="bold"><strong>retp</strong></span> parameter returns the number of entries 119 <code class="methodname">DB_ENV->txn_recover()</code> has filled in, in the array. 120 </p> 121 </div> 122 <div class="sect3" lang="en" xml:lang="en"> 123 <div class="titlepage"> 124 <div> 125 <div> 126 <h4 class="title"><a id="id1710116"></a>flags</h4> 127 </div> 128 </div> 129 </div> 130 <p> 131 The <span class="bold"><strong>flags</strong></span> parameter must be set to 132 one of the following values: 133 </p> 134 <div class="itemizedlist"> 135 <ul type="disc"> 136 <li> 137 <p> 138 <code class="literal">DB_FIRST</code> 139 </p> 140 <p> 141 Begin returning a list of prepared, but not yet resolved transactions. 142 Specifying this flag begins a new pass over all prepared, but not yet 143 completed transactions, regardless of whether they have already been 144 returned in previous calls to <code class="methodname">DB_ENV->txn_recover.()</code> Calls to 145 <code class="methodname">DB_ENV->txn_recover()</code> from different threads of control should not be 146 intermixed in the same environment. 147 </p> 148 </li> 149 <li> 150 <p> 151 <code class="literal">DB_NEXT</code> 152 </p> 153 <p> 154 Continue returning a list of prepared, but not yet resolved 155 transactions, starting where the last call to 156 <code class="methodname">DB_ENV->txn_recover()</code> 157 left off. 158 </p> 159 </li> 160 </ul> 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="id1710261"></a>preplist</h4> 168 </div> 169 </div> 170 </div> 171 <p> 172 The <span class="bold"><strong>preplist</strong></span> parameter references 173 memory into which the list of transactions to be resolved by the 174 application is copied. 175 </p> 176 </div> 177 </div> 178 <div class="sect2" lang="en" xml:lang="en"> 179 <div class="titlepage"> 180 <div> 181 <div> 182 <h3 class="title"><a id="id1709564"></a>Class</h3> 183 </div> 184 </div> 185 </div> 186 <p> 187 <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a>, <a class="link" href="txn.html" title="Chapter 12. The DB_TXN Handle">DB_TXN</a> 188 </p> 189 </div> 190 <div class="sect2" lang="en" xml:lang="en"> 191 <div class="titlepage"> 192 <div> 193 <div> 194 <h3 class="title"><a id="id1710363"></a>See Also</h3> 195 </div> 196 </div> 197 </div> 198 <p> 199 <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a> 200 </p> 201 </div> 202 </div> 203 <div class="navfooter"> 204 <hr /> 205 <table width="100%" summary="Navigation footer"> 206 <tr> 207 <td width="40%" align="left"><a accesskey="p" href="txnprepare.html">Prev</a> </td> 208 <td width="20%" align="center"> 209 <a accesskey="u" href="txn.html">Up</a> 210 </td> 211 <td width="40%" align="right"> <a accesskey="n" href="txnset_name.html">Next</a></td> 212 </tr> 213 <tr> 214 <td width="40%" align="left" valign="top">DB_TXN->prepare() </td> 215 <td width="20%" align="center"> 216 <a accesskey="h" href="index.html">Home</a> 217 </td> 218 <td width="40%" align="right" valign="top"> DB_TXN->set_name()</td> 219 </tr> 220 </table> 221 </div> 222 </body> 223</html> 224