1<!--$Id--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DbEnv::log_set_config</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DbEnv::log_set_config</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbEnv::log_set_config(u_int32_t flags, int onoff); 26<p> 27int 28DbEnv::log_get_config(u_int32_t which, int *onoffp) 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DbEnv::log_set_config</b> 32<p>The DbEnv::log_set_config method configures the Berkeley DB logging 33subsystem.</p> 34<p>The DbEnv::log_set_config method configures a database environment, not only operations 35performed using the specified <a href="../api_cxx/env_class.html">DbEnv</a> handle.</p> 36<p>The DbEnv::log_set_config method may be called at any time during the life of the 37application.</p> 38<p>The DbEnv::log_set_config method 39either returns a non-zero error value 40or throws an exception that encapsulates a non-zero error value on 41failure, and returns 0 on success. 42</p> 43<b>Parameters</b> <br> 44 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set by bitwise inclusively <b>OR</b>'ing together one or more 45of the following values: 46<br> 47<a name="2"><!--meow--></a> 48<b><a name="DB_LOG_DIRECT">DB_LOG_DIRECT</a></b><ul compact><li>Turn off system buffering of Berkeley DB log files to avoid double caching. 49<p>Calling DbEnv::log_set_config with the DB_LOG_DIRECT flag only affects 50the specified <a href="../api_cxx/env_class.html">DbEnv</a> handle (and any other Berkeley DB handles opened 51within the scope of that handle). 52For consistent behavior across the environment, all <a href="../api_cxx/env_class.html">DbEnv</a> 53handles opened in the environment must either set the DB_LOG_DIRECT flag 54or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration 55file.</p> 56<p>The DB_LOG_DIRECT flag may be used to configure Berkeley DB at any time during 57the life of the application.</p></ul> 58<a name="3"><!--meow--></a> 59<b><a name="DB_LOG_DSYNC">DB_LOG_DSYNC</a></b><ul compact><li>Configure Berkeley DB to flush log writes to the backing disk before returning 60from the write system call, rather than flushing log writes explicitly 61in a separate system call, as necessary. This is only available on some 62systems (for example, systems supporting the IEEE/ANSI Std 1003.1 (POSIX) standard 63O_DSYNC flag, or systems supporting the Windows FILE_FLAG_WRITE_THROUGH 64flag). This flag may result in inaccurate file modification times and 65other file-level information for Berkeley DB log files. This flag may offer 66a performance increase on some systems and a performance decrease on 67others. 68<p>Calling DbEnv::log_set_config with the DB_LOG_DSYNC flag only affects 69the specified <a href="../api_cxx/env_class.html">DbEnv</a> handle (and any other Berkeley DB handles opened 70within the scope of that handle). 71For consistent behavior across the environment, all <a href="../api_cxx/env_class.html">DbEnv</a> 72handles opened in the environment must either set the DB_LOG_DSYNC flag 73or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration 74file.</p> 75<p>The DB_LOG_DSYNC flag may be used to configure Berkeley DB at any time during 76the life of the application.</p></ul> 77<a name="4"><!--meow--></a> 78<b><a name="DB_LOG_AUTO_REMOVE">DB_LOG_AUTO_REMOVE</a></b><ul compact><li>If set, Berkeley DB will automatically remove log files that are no longer 79needed. 80<p>Automatic log file removal is likely to make catastrophic recovery 81impossible.</p> 82<p>Replication applications will rarely want to configure automatic log 83file removal as it increases the likelihood a master will be unable to 84satisfy a client's request for a recent log record.</p> 85<p>Calling DbEnv::log_set_config with the DB_LOG_AUTO_REMOVE flag affects the 86database environment, including all threads of control accessing the 87database environment.</p> 88<p>The DB_LOG_AUTO_REMOVE flag may be used to configure Berkeley DB at any time during 89the life of the application.</p></ul> 90<a name="5"><!--meow--></a> 91<b><a name="DB_LOG_IN_MEMORY">DB_LOG_IN_MEMORY</a></b><ul compact><li>If set, maintain transaction logs in memory rather than on disk. This 92means that transactions exhibit the ACI (atomicity, consistency, and 93isolation) properties, but not D (durability); that is, database 94integrity will be maintained, but if the application or system fails, 95integrity will not persist. All database files must be verified and/or 96restored from a replication group master or archival backup after 97application or system failure. 98<p>When in-memory logs are configured and no more log buffer space is 99available, Berkeley DB methods may return an additional error value, 100<a name="DB_LOG_BUFFER_FULL">DB_LOG_BUFFER_FULL</a>. When choosing log buffer and file sizes 101for in-memory logs, applications should ensure the in-memory log buffer 102size is large enough that no transaction will ever span the entire 103buffer, and avoid a state where the in-memory buffer is full and no 104space can be freed because a transaction that started in the first log 105"file" is still active.</p> 106<p>Calling DbEnv::log_set_config with the DB_LOG_IN_MEMORY flag affects the 107database environment, including all threads of control accessing the 108database environment.</p> 109<p>The DB_LOG_IN_MEMORY flag may be used to configure Berkeley DB only before the 110<a href="../api_cxx/env_open.html">DbEnv::open</a> method is called.</p></ul> 111<a name="6"><!--meow--></a> 112<b><a name="DB_LOG_ZERO">DB_LOG_ZERO</a></b><ul compact><li>If set, zero all pages of a log file when that log file is created. This 113has shown to provide greater transaction throughput in some environments. 114The log file will be zeroed by the thread which needs to re-create the new log 115file. Other threads may not write to the log file while this is happening. 116<p>Calling DbEnv::log_set_config with the DB_LOG_ZERO flag affects the 117database environment, including all threads of control accessing the 118database environment.</p> 119<p>The DB_LOG_ZERO flag may be used to configure Berkeley DB only before the 120<a href="../api_cxx/env_open.html">DbEnv::open</a> method is called.</p></ul> 121<br></ul> 122 <b>onoff</b><ul compact><li>If the <b>onoff</b> parameter is zero, the specified flags are cleared; 123otherwise they are set.</ul> 124<br> 125<br><b>Errors</b> 126<p>The DbEnv::log_set_config method 127may fail and throw 128<a href="../api_cxx/except_class.html">DbException</a>, 129encapsulating one of the following non-zero errors, or return one of 130the following non-zero errors:</p> 131<br> 132<b>EINVAL</b><ul compact><li>An 133invalid flag value or parameter was specified.</ul> 134<br> 135<hr size=1 noshade> 136<b>Description: DbEnv::log_get_config</b> 137<p>The DbEnv::log_get_config method returns whether the specified <b>which</b> 138parameter is currently set or not.</p> 139<p>The DbEnv::log_get_config method may be called at any time during the life of the 140application.</p> 141<p>The DbEnv::log_get_config method 142either returns a non-zero error value 143or throws an exception that encapsulates a non-zero error value on 144failure, and returns 0 on success. 145</p> 146<b>Parameters</b> <br> 147 <b>which</b><ul compact><li>The <b>which</b> parameter is the message value for which configuration 148is being checked.</ul> 149 <b>onoffp</b><ul compact><li>The <b>onoffp</b> parameter references memory into which 150 the configuration of the specified <b>which</b> parameter is copied.</ul> If the returned <b>onoff</b> value is zero, the parameter is off; 151otherwise on. 152<br> 153<hr size=1 noshade> 154<br><b>Class</b> 155<a href="../api_cxx/env_class.html">DbEnv</a> 156<br><b>See Also</b> 157<a href="../api_cxx/env_list.html">Database Environments and Related Methods</a> 158</tt> 159<table width="100%"><tr><td><br></td><td align=right> 160<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 161</td></tr></table> 162<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 163</body> 164</html> 165