| 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::log_archive()</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="lsn.html" title="Chapter 8. The DbLsn Handle" /> |
| 11 | <link rel="prev" href="envget_lg_regionmax.html" title="DbEnv::get_lg_regionmax()" /> |
| 12 | <link rel="next" href="logcursor.html" title="DbEnv::log_cursor()" /> |
| 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::log_archive()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="envget_lg_regionmax.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 8. |
| 26 | The DbLsn Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="logcursor.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="logarchive"></a>DbEnv::log_archive()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbEnv::log_archive(char *(*listp)[], u_int32_t flags);</pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DbEnv::log_archive()</code> method returns an array of log or database |
| 47 | filenames. |
| 48 | </p> |
| 49 | <p> |
| 50 | By default, <code class="methodname">DbEnv::log_archive()</code> returns the names of all of the |
| 51 | log files that are no longer in use (for example, that are no longer involved in active |
| 52 | transactions), and that may safely be archived for catastrophic recovery and then removed |
| 53 | from the system. If there are no filenames to return, the memory location to which |
| 54 | <span class="bold"><strong>listp</strong></span> refers will be set to NULL. |
| 55 | </p> |
| 56 | <p> |
| 57 | When Replication Manager is in use, log archiving is |
| 58 | performed in a replication group-aware manner such that the |
| 59 | log file status of other sites in the group is considered to |
| 60 | determine if a log file is in use. |
| 61 | </p> |
| 62 | <p> |
| 63 | |
| 64 | Arrays of log filenames are stored in allocated memory. If application-specific allocation |
| 65 | routines have been declared (see <a class="xref" href="envset_alloc.html" title="DbEnv::set_alloc()">DbEnv::set_alloc()</a> |
| 66 | for more information), they are used to allocate the memory; otherwise, the standard |
| 67 | C library <span class="bold"><strong>malloc</strong></span>(3) is used. The caller is responsible |
| 68 | for deallocating the memory. To deallocate the memory, free the memory reference; |
| 69 | references inside the returned memory need not be individually freed. |
| 70 | </p> |
| 71 | <p> |
| 72 | Log cursor handles (returned by the <a class="xref" href="logcursor.html" title="DbEnv::log_cursor()">DbEnv::log_cursor()</a> |
| 73 | method) may have open file descriptors for log files in the database environment. Also, |
| 74 | the Berkeley DB interfaces to the database environment logging subsystem (for example, |
| 75 | <a class="xref" href="logput.html" title="DbEnv::log_put()">DbEnv::log_put()</a> and <a class="xref" href="txnabort.html" title="DbTxn::abort()">DbTxn::abort()</a> ) may allocate log cursors and have open file descriptors |
| 76 | for log files as well. On operating systems where filesystem related system calls (for |
| 77 | example, rename and unlink on Windows/NT) can fail if a process has an open file descriptor |
| 78 | for the affected file, attempting to move or remove the log files listed by |
| 79 | <code class="methodname">DbEnv::log_archive()</code> may fail. All Berkeley DB internal use of log |
| 80 | cursors operates on active log files only and furthermore, is short-lived in nature. So, |
| 81 | an application seeing such a failure should be restructured to close any open log cursors |
| 82 | it may have, and otherwise to retry the operation until it succeeds. (Although the latter |
| 83 | is not likely to be necessary; it is hard to imagine a reason to move or rename a log file |
| 84 | in which transactions are being logged or aborted.) |
| 85 | </p> |
| 86 | <p> |
| 87 | See <a class="link" href="db_archive.html" title="db_archive">db_archive</a> for more information on |
| 88 | database archival procedures. |
| 89 | </p> |
| 90 | <p> |
| 91 | The <code class="methodname">DbEnv::log_archive()</code> <span> |
| 92 | |
| 93 | <span> |
| 94 | method either returns a non-zero error value or throws an |
| 95 | exception that encapsulates a non-zero error value on |
| 96 | failure, and returns 0 on success. |
| 97 | </span> |
| 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="idp8273896"></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="idp8273248"></a>listp</h4> |
| 113 | </div> |
| 114 | </div> |
| 115 | </div> |
| 116 | <p> |
| 117 | The <span class="bold"><strong>listp</strong></span> parameter references memory |
| 118 | into which the allocated array of log or database filenames is copied. |
| 119 | If there are no filenames to return, the memory location to which |
| 120 | <span class="bold"><strong>listp</strong></span> refers will be set to NULL. |
| 121 | </p> |
| 122 | </div> |
| 123 | <div class="sect3" lang="en" xml:lang="en"> |
| 124 | <div class="titlepage"> |
| 125 | <div> |
| 126 | <div> |
| 127 | <h4 class="title"><a id="idp8276912"></a>flags</h4> |
| 128 | </div> |
| 129 | </div> |
| 130 | </div> |
| 131 | <p> |
| 132 | The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 |
| 133 | or by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing |
| 134 | together one or more of the following values: |
| 135 | </p> |
| 136 | <div class="itemizedlist"> |
| 137 | <ul type="disc"> |
| 138 | <li> |
| 139 | <p><a id="archive_DB_ARCH_ABS"></a> |
| 140 | <code class="literal">DB_ARCH_ABS</code> |
| 141 | </p> |
| 142 | <p> |
| 143 | All pathnames are returned as absolute pathnames, instead of relative |
| 144 | to the database home directory. |
| 145 | </p> |
| 146 | </li> |
| 147 | <li> |
| 148 | <p><a id="archive_DB_ARCH_DATA"></a> |
| 149 | <code class="literal">DB_ARCH_DATA</code> |
| 150 | </p> |
| 151 | <p> |
| 152 | Return the database files that need to be archived in order to recover |
| 153 | the database from catastrophic failure. If any of the database files |
| 154 | have not been accessed during the lifetime of the current log files, |
| 155 | <code class="methodname">DbEnv::log_archive()</code> will not include them in this list. It is also |
| 156 | possible that some of the files referred to by the log have since been |
| 157 | deleted from the system. |
| 158 | </p> |
| 159 | <p> |
| 160 | The <code class="literal">DB_ARCH_DATA</code> and <code class="literal">DB_ARCH_LOG flags</code> are mutually exclusive. |
| 161 | </p> |
| 162 | </li> |
| 163 | <li> |
| 164 | <p><a id="archive_DB_ARCH_LOG"></a> |
| 165 | <code class="literal">DB_ARCH_LOG</code> |
| 166 | </p> |
| 167 | <p> |
| 168 | Return all the log filenames, regardless of whether or not they are in |
| 169 | use. |
| 170 | </p> |
| 171 | <p> |
| 172 | The <code class="literal">DB_ARCH_DATA</code> and <code class="literal">DB_ARCH_LOG flags</code> are mutually exclusive. |
| 173 | </p> |
| 174 | </li> |
| 175 | <li> |
| 176 | <p><a id="archive_DB_ARCH_REMOVE"></a> |
| 177 | <code class="literal">DB_ARCH_REMOVE</code> |
| 178 | </p> |
| 179 | <p> |
| 180 | Remove log files that are no longer needed; no filenames are returned. |
| 181 | Automatic log file removal is likely to make catastrophic recovery |
| 182 | impossible. |
| 183 | </p> |
| 184 | <p> |
| 185 | The <code class="literal">DB_ARCH_REMOVE</code> flag may not be specified with any other flag. |
| 186 | </p> |
| 187 | </li> |
| 188 | </ul> |
| 189 | </div> |
| 190 | </div> |
| 191 | </div> |
| 192 | <div class="sect2" lang="en" xml:lang="en"> |
| 193 | <div class="titlepage"> |
| 194 | <div> |
| 195 | <div> |
| 196 | <h3 class="title"><a id="idp8293096"></a>Errors</h3> |
| 197 | </div> |
| 198 | </div> |
| 199 | </div> |
| 200 | <p> |
| 201 | The <code class="methodname">DbEnv::log_archive()</code> <span> |
| 202 | |
| 203 | <span> |
| 204 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 205 | exception, encapsulating one of the following non-zero errors, or return one |
| 206 | of the following non-zero errors: |
| 207 | </span> |
| 208 | </span> |
| 209 | </p> |
| 210 | <div class="sect3" lang="en" xml:lang="en"> |
| 211 | <div class="titlepage"> |
| 212 | <div> |
| 213 | <div> |
| 214 | <h4 class="title"><a id="idp8288920"></a>EINVAL</h4> |
| 215 | </div> |
| 216 | </div> |
| 217 | </div> |
| 218 | <p> |
| 219 | An invalid flag value or parameter was specified. |
| 220 | </p> |
| 221 | </div> |
| 222 | </div> |
| 223 | <div class="sect2" lang="en" xml:lang="en"> |
| 224 | <div class="titlepage"> |
| 225 | <div> |
| 226 | <div> |
| 227 | <h3 class="title"><a id="idp8297880"></a>Class</h3> |
| 228 | </div> |
| 229 | </div> |
| 230 | </div> |
| 231 | <p> |
| 232 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>, |
| 233 | <a class="link" href="logc.html" title="The DbLogc Handle">DbLogc</a>, |
| 234 | <a class="link" href="lsn.html" title="Chapter 8. The DbLsn Handle">DbLsn</a> |
| 235 | </p> |
| 236 | </div> |
| 237 | <div class="sect2" lang="en" xml:lang="en"> |
| 238 | <div class="titlepage"> |
| 239 | <div> |
| 240 | <div> |
| 241 | <h3 class="title"><a id="idp8273352"></a>See Also</h3> |
| 242 | </div> |
| 243 | </div> |
| 244 | </div> |
| 245 | <p> |
| 246 | <a class="xref" href="lsn.html#loglist" title="Logging Subsystem and Related Methods">Logging Subsystem and Related Methods</a> |
| 247 | </p> |
| 248 | </div> |
| 249 | </div> |
| 250 | <div class="navfooter"> |
| 251 | <hr /> |
| 252 | <table width="100%" summary="Navigation footer"> |
| 253 | <tr> |
| 254 | <td width="40%" align="left"><a accesskey="p" href="envget_lg_regionmax.html">Prev</a> </td> |
| 255 | <td width="20%" align="center"> |
| 256 | <a accesskey="u" href="lsn.html">Up</a> |
| 257 | </td> |
| 258 | <td width="40%" align="right"> <a accesskey="n" href="logcursor.html">Next</a></td> |
| 259 | </tr> |
| 260 | <tr> |
| 261 | <td width="40%" align="left" valign="top">DbEnv::get_lg_regionmax() </td> |
| 262 | <td width="20%" align="center"> |
| 263 | <a accesskey="h" href="index.html">Home</a> |
| 264 | </td> |
| 265 | <td width="40%" align="right" valign="top"> DbEnv::log_cursor()</td> |
| 266 | </tr> |
| 267 | </table> |
| 268 | </div> |
| 269 | </body> |
| 270 | </html> |