Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / docs / gsg_txn / JAVA / nodurabletxn.html
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>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" />
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">Non-Durable Transactions</th>
22         </tr>
23         <tr>
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>
27         </tr>
28       </table>
29       <hr />
30     </div>
31     <div class="sect1" lang="en" xml:lang="en">
32       <div class="titlepage">
33         <div>
34           <div>
35             <h2 class="title" style="clear: both"><a id="nodurabletxn"></a>Non-Durable Transactions</h2>
36           </div>
37         </div>
38       </div>
39       <p>
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.
45         </p>
46       <p>
47             You may want non-durable transactions for performance
48             reasons. For example, you might be using transactions
49             simply for the isolation guarantee. 
50             
51             <span>
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
55             transaction commit.
56             </span>
57             
58         </p>
59       <p>
60             There are several ways to remove the durability guarantee
61             for your transactions:
62         </p>
63       <div class="itemizedlist">
64         <ul type="disc">
65           <li>
66             <p>
67                     Specify          
68                         
69                         <span>
70                             <code class="literal">true</code> to the
71                             <code class="methodname">EnvironmentConfig.setTxnNoSync()</code>
72                             method.
73                         </span>
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
77                      long-term storage.
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.
82                </p>
83             <p>
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> 
87                         or OS crash.
88                 </p>
89             <p>
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 
93                         
94                         <span>method</span>
95                     for all of the environment handles used in your application.
96                 </p>
97             <p>
98                     You can achieve this behavior on a transaction by transaction basis by
99                         
100
101                         <span>
102                             using <code class="methodname">Transaction.commitNoSync()</code>
103                                   
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
106                             transaction.
107                         </span>
108
109                 </p>
110           </li>
111           <li>
112             <p>
113                     Specify
114                     
115
116                         <span>
117                             <code class="literal">true</code> to the
118                             <code class="methodname">EnvironmentConfig.setTxnWriteNoSync()</code>
119                             method.
120                         </span>
121
122                         This causes 
123                         <span>
124                             logging 
125                         </span>
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
133                         by the OS.
134                    </p>
135             <p>
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
139                             
140                             <span><code class="methodname">EnvironmentConfig.setTxnNoSync()</code>.</span>
141                 </p>
142             <p>
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 
146                         
147                         <span>method</span>
148                     for all of the environment handles used in your application.
149                 </p>
150             <p>
151                     You can achieve this behavior on a transaction by transaction basis by
152                         <span>
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
156                             transaction.
157                         </span>
158                 </p>
159           </li>
160           <li>
161             <p>
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.
165                     See 
166                     <a class="xref" href="logconfig.html#inmemorylogging" title="Configuring In-Memory Logging">Configuring In-Memory Logging</a>
167                     for more information.
168                 </p>
169           </li>
170         </ul>
171       </div>
172     </div>
173     <div class="navfooter">
174       <hr />
175       <table width="100%" summary="Navigation footer">
176         <tr>
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>
180           </td>
181           <td width="40%" align="right"> <a accesskey="n" href="abortresults.html">Next</a></td>
182         </tr>
183         <tr>
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>
187           </td>
188           <td width="40%" align="right" valign="top"> Aborting a Transaction</td>
189         </tr>
190       </table>
191     </div>
192   </body>
193 </html>