Debian Codegraph @

docs/gsg_txn/CXX/nodurabletxn.html

raw
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 <span>
69 <code class="literal">DB_TXN_NOSYNC</code> using the
70
71 <code class="methodname">DbEnv::set_flags()</code>
72 method.
73 </span>
74
75 This causes DB to not synchronously force any log
76 data to disk upon transaction commit. That is, the modifications are held entirely
77 in the in-memory cache and the logging information is not forced to the filesystem for
78 long-term storage.
79 Note, however, that the logging
80 data will eventually make it to the filesystem (assuming no
81 application or OS crashes) as a part of DB's
82 management of its logging buffers and/or cache.
83 </p>
84 <p>
85 This form of a commit provides a weak durability
86 guarantee because data loss can occur due to
87 an application
88 or OS crash.
89 </p>
90 <p>
91 This behavior is specified on a per-environment
92 handle basis. In order for your application to exhibit consistent
93 behavior, you need to specify this
94 <span>flag</span>
95
96 for all of the environment handles used in your application.
97 </p>
98 <p>
99 You can achieve this behavior on a transaction by transaction basis by
100 <span>
101 specifying <code class="literal">DB_TXN_NOSYNC</code> to the
102
103 <code class="methodname">DbTxn::commit()</code>
104
105 method.
106 </span>
107
108
109
110 </p>
111 </li>
112 <li>
113 <p>
114 Specify
115 <span>
116 <code class="literal">DB_TXN_WRITE_NOSYNC</code> using the
117
118 <code class="methodname">DbEnv::set_flags()</code>
119 method.
120 </span>
121
122
123
124 This causes
125 <span>
126 logging
127 </span>
128 data to be synchronously
129 written to the OS's file system buffers upon
130 transaction commit. The data will eventually be
131 written to disk, but this occurs when the
132 operating system chooses to schedule the
133 activity; the transaction commit can complete
134 successfully before this disk I/O is performed
135 by the OS.
136 </p>
137 <p>
138 This form of commit protects you against application
139 crashes, but not against OS
140 crashes. This method offers less room for the possibility of data loss than does
141 <span><code class="literal">DB_TXN_NOSYNC</code>.</span>
142
143 </p>
144 <p>
145 This behavior is specified on a per-environment
146 handle basis. In order for your application to exhibit consistent
147 behavior, you need to specify this
148 <span>flag</span>
149
150 for all of the environment handles used in your application.
151 </p>
152 </li>
153 <li>
154 <p>
155 Maintain your logs entirely in-memory. In this
156 case, your logs are never written to disk. The
157 result is that you lose all durability guarantees.
158 See
159 <a class="xref" href="logconfig.html#inmemorylogging" title="Configuring In-Memory Logging">Configuring In-Memory Logging</a>
160 for more information.
161 </p>
162 </li>
163 </ul>
164 </div>
165 </div>
166 <div class="navfooter">
167 <hr />
168 <table width="100%" summary="Navigation footer">
169 <tr>
170 <td width="40%" align="left"><a accesskey="p" href="usingtxns.html">Prev</a> </td>
171 <td width="20%" align="center">
172 <a accesskey="u" href="usingtxns.html">Up</a>
173 </td>
174 <td width="40%" align="right"> <a accesskey="n" href="abortresults.html">Next</a></td>
175 </tr>
176 <tr>
177 <td width="40%" align="left" valign="top">Chapter 3. Transaction Basics </td>
178 <td width="20%" align="center">
179 <a accesskey="h" href="index.html">Home</a>
180 </td>
181 <td width="40%" align="right" valign="top"> Aborting a Transaction</td>
182 </tr>
183 </table>
184 </div>
185 </body>
186 </html>