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">
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>Non-Durable Transactions</title>
7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Getting Started with Berkeley DB Transaction Processing" />
10 <link rel="up" href="usingtxns.html" title="Chapter 3. Transaction Basics" />
11 <link rel="prev" href="usingtxns.html" title="Chapter 3. Transaction Basics" />
12 <link rel="next" href="abortresults.html" title="Aborting a Transaction" />
15 <div xmlns="" class="navheader">
17 <p>Library Version 11.2.5.3</p>
19 <table width="100%" summary="Navigation header">
21 <th colspan="3" align="center">Non-Durable Transactions</th>
24 <td width="20%" align="left"><a accesskey="p" href="usingtxns.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 3. Transaction Basics</th>
26 <td width="20%" align="right"> <a accesskey="n" href="abortresults.html">Next</a></td>
31 <div class="sect1" lang="en" xml:lang="en">
32 <div class="titlepage">
35 <h2 class="title" style="clear: both"><a id="nodurabletxn"></a>Non-Durable Transactions</h2>
40 As previously noted, by default transaction commits are
41 durable because they cause the modifications performed
42 under the transaction to be synchronously recorded in
43 your on-disk log files. However, it is possible to use
44 non-durable transactions.
47 You may want non-durable transactions for performance
48 reasons. For example, you might be using transactions
49 simply for the isolation guarantee.
52 In this case, you might
53 not want a durability guarantee and so you may want to
54 prevent the disk I/O that normally accompanies a
60 There are several ways to remove the durability guarantee
61 for your transactions:
63 <div class="itemizedlist">
70 <code class="literal">true</code> to the
71 <code class="methodname">EnvironmentConfig.setTxnNoSync()</code>
74 This causes DB to not synchronously force any log
75 data to disk upon transaction commit. That is, the modifications are held entirely
76 in the in-memory cache and the logging information is not forced to the filesystem for
78 Note, however, that the logging
79 data will eventually make it to the filesystem (assuming no
80 application or OS crashes) as a part of DB's
81 management of its logging buffers and/or cache.
84 This form of a commit provides a weak durability
85 guarantee because data loss can occur due to
86 an application<span>, JVM,</span>
90 This behavior is specified on a per-environment
91 handle basis. In order for your application to exhibit consistent
92 behavior, you need to specify this
95 for all of the environment handles used in your application.
98 You can achieve this behavior on a transaction by transaction basis by
102 using <code class="methodname">Transaction.commitNoSync()</code>
104 to commit your transaction, or by specifying <code class="literal">true</code> to the
105 <code class="methodname">TransactionConfig.setNoSync()</code> method when starting the
117 <code class="literal">true</code> to the
118 <code class="methodname">EnvironmentConfig.setTxnWriteNoSync()</code>
126 data to be synchronously
127 written to the OS's file system buffers upon
128 transaction commit. The data will eventually be
129 written to disk, but this occurs when the
130 operating system chooses to schedule the
131 activity; the transaction commit can complete
132 successfully before this disk I/O is performed
136 This form of commit protects you against application
137 <span>and JVM</span> crashes, but not against OS
138 crashes. This method offers less room for the possibility of data loss than does
140 <span><code class="methodname">EnvironmentConfig.setTxnNoSync()</code>.</span>
143 This behavior is specified on a per-environment
144 handle basis. In order for your application to exhibit consistent
145 behavior, you need to specify this
148 for all of the environment handles used in your application.
151 You can achieve this behavior on a transaction by transaction basis by
153 using <code class="methodname">Transaction.commitWriteNoSync()</code>
154 to commit your transaction, or by specifying <code class="literal">true</code> to
155 <code class="methodname">TransactionConfig.setWriteNoSync()</code> method when starting the
162 Maintain your logs entirely in-memory. In this
163 case, your logs are never written to disk. The
164 result is that you lose all durability guarantees.
166 <a class="xref" href="logconfig.html#inmemorylogging" title="Configuring In-Memory Logging">Configuring In-Memory Logging</a>
167 for more information.
173 <div class="navfooter">
175 <table width="100%" summary="Navigation footer">
177 <td width="40%" align="left"><a accesskey="p" href="usingtxns.html">Prev</a> </td>
178 <td width="20%" align="center">
179 <a accesskey="u" href="usingtxns.html">Up</a>
181 <td width="40%" align="right"> <a accesskey="n" href="abortresults.html">Next</a></td>
184 <td width="40%" align="left" valign="top">Chapter 3. Transaction Basics </td>
185 <td width="20%" align="center">
186 <a accesskey="h" href="index.html">Home</a>
188 <td width="40%" align="right" valign="top"> Aborting a Transaction</td>