Debian Codegraph @

docs/programmer_reference/txn.html

raw symbols SCIP
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>Chapter 19.  The Transaction Subsystem</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="Berkeley DB Programmer's Reference Guide" />
10 <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
11 <link rel="prev" href="mp_warm.html" title="Warming the memory pool" />
12 <link rel="next" href="txn_config.html" title="Configuring transactions" />
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">Chapter 19. 
22 The Transaction Subsystem
23 </th>
24 </tr>
25 <tr>
26 <td width="20%" align="left"><a accesskey="p" href="mp_warm.html">Prev</a> </td>
27 <th width="60%" align="center"> </th>
28 <td width="20%" align="right"> <a accesskey="n" href="txn_config.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="chapter" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title"><a id="txn"></a>Chapter 19. 
38 The Transaction Subsystem
39 </h2>
40 </div>
41 </div>
42 </div>
43 <div class="toc">
44 <p>
45 <b>Table of Contents</b>
46 </p>
47 <dl>
48 <dt>
49 <span class="sect1">
50 <a href="txn.html#txn_intro">Introduction to the transaction subsystem</a>
51 </span>
52 </dt>
53 <dt>
54 <span class="sect1">
55 <a href="txn_config.html">Configuring transactions</a>
56 </span>
57 </dt>
58 <dt>
59 <span class="sect1">
60 <a href="txn_limits.html">Transaction limits</a>
61 </span>
62 </dt>
63 <dd>
64 <dl>
65 <dt>
66 <span class="sect2">
67 <a href="txn_limits.html#idp53352320">Transaction IDs</a>
68 </span>
69 </dt>
70 <dt>
71 <span class="sect2">
72 <a href="txn_limits.html#idp53275624">Cursors</a>
73 </span>
74 </dt>
75 <dt>
76 <span class="sect2">
77 <a href="txn_limits.html#idp53223368">Multiple Threads of Control</a>
78 </span>
79 </dt>
80 </dl>
81 </dd>
82 </dl>
83 </div>
84 <div class="sect1" lang="en" xml:lang="en">
85 <div class="titlepage">
86 <div>
87 <div>
88 <h2 class="title" style="clear: both"><a id="txn_intro"></a>Introduction to the transaction subsystem</h2>
89 </div>
90 </div>
91 </div>
92 <p>The Transaction subsystem makes operations atomic, consistent, isolated,
93 and durable in the face of system and application failures. The subsystem
94 requires that the data be properly logged and locked in order to attain
95 these properties. Berkeley DB contains all the components necessary to
96 transaction-protect the Berkeley DB access methods, and other forms of data may
97 be protected if they are logged and locked appropriately.</p>
98 <p>The Transaction subsystem is created, initialized, and opened by calls to
99 <a href="../api_reference/C/envopen.html" class="olink">DB_ENV-&gt;open()</a> with the <a href="../api_reference/C/envopen.html#envopen_DB_INIT_TXN" class="olink">DB_INIT_TXN</a> flag specified. Note
100 that enabling transactions automatically enables logging, but does not
101 enable locking because a single thread of control that needed atomicity
102 and recoverability would not require it.</p>
103 <p>The <a href="../api_reference/C/txnbegin.html" class="olink">DB_ENV-&gt;txn_begin()</a> function starts a transaction, returning an opaque
104 handle to a transaction. If the parent parameter to <a href="../api_reference/C/txnbegin.html" class="olink">DB_ENV-&gt;txn_begin()</a> is
105 non-NULL, the new transaction is a child of the designated parent
106 transaction.</p>
107 <p>The <a href="../api_reference/C/txnabort.html" class="olink">DB_TXN-&gt;abort()</a> function ends the designated transaction and causes
108 all updates performed by the transaction to be undone. The end result is
109 that the database is left in a state identical to the state that existed
110 prior to the <a href="../api_reference/C/txnbegin.html" class="olink">DB_ENV-&gt;txn_begin()</a>. If the aborting transaction has any child
111 transactions associated with it (even ones that have already been
112 committed), they are also aborted. Any transactions that are unresolved
113 (neither committed nor aborted) when the application or system fails
114 are aborted during recovery.</p>
115 <p>The <a href="../api_reference/C/txncommit.html" class="olink">DB_TXN-&gt;commit()</a> function ends the designated transaction and makes
116 all the updates performed by the transaction permanent, even in the face
117 of application or system failure. If this is a parent transaction
118 committing, all child transactions that individually committed or
119 had not been resolved are also committed.</p>
120 <p>Transactions are identified by 32-bit unsigned integers. The ID
121 associated with any transaction can be obtained using the <a href="../api_reference/C/txnid.html" class="olink">DB_TXN-&gt;id()</a>
122 function. If an application is maintaining information outside of Berkeley DB
123 it wants to transaction-protect, it should use this transaction ID as
124 the locking ID.</p>
125 <p>The <a href="../api_reference/C/txncheckpoint.html" class="olink">DB_ENV-&gt;txn_checkpoint()</a> function causes a transaction checkpoint. A
126 checkpoint is performed using to a specific log sequence number (LSN),
127 referred to as the checkpoint LSN. When a checkpoint completes
128 successfully, it means that all data buffers whose updates are described
129 by LSNs less than the checkpoint LSN have been written to disk. This, in
130 turn, means that the log records less than the checkpoint LSN are no
131 longer necessary for normal recovery (although they would be required for
132 catastrophic recovery if the database files were lost), and all log files
133 containing only records prior to the checkpoint LSN may be safely archived
134 and removed.</p>
135 <p>The time required to run normal recovery is proportional to the amount
136 of work done between checkpoints. If a large number of modifications
137 happen between checkpoints, many updates recorded in the log may
138 not have been written to disk when failure occurred, and recovery may
139 take longer to run. Generally, if the interval between checkpoints is
140 short, data may be being written to disk more frequently, but the
141 recovery time will be shorter. Often, the checkpoint interval is tuned
142 for each specific application.</p>
143 <p>The <a href="../api_reference/C/txnstat.html" class="olink">DB_TXN-&gt;stat()</a> method returns information about the status of the
144 transaction subsystem. It is the programmatic interface used by the
145 <a href="../api_reference/C/db_stat.html" class="olink">db_stat</a> utility.</p>
146 <p>The transaction system is closed by a call to <a href="../api_reference/C/envclose.html" class="olink">DB_ENV-&gt;close()</a>.</p>
147 <p>Finally, the entire transaction system may be removed using the
148 <a href="../api_reference/C/envremove.html" class="olink">DB_ENV-&gt;remove()</a> method.</p>
149 <p>For more information on the transaction subsystem methods, see the <a href="../api_reference/C/txn.html#txnlist" class="olink">Transaction Subsystem and Related Methods</a> section in the <em class="citetitle">Berkeley DB C API Reference Guide.</em> </p>
150 </div>
151 </div>
152 <div class="navfooter">
153 <hr />
154 <table width="100%" summary="Navigation footer">
155 <tr>
156 <td width="40%" align="left"><a accesskey="p" href="mp_warm.html">Prev</a> </td>
157 <td width="20%" align="center"> </td>
158 <td width="40%" align="right"> <a accesskey="n" href="txn_config.html">Next</a></td>
159 </tr>
160 <tr>
161 <td width="40%" align="left" valign="top">Warming the memory pool </td>
162 <td width="20%" align="center">
163 <a accesskey="h" href="index.html">Home</a>
164 </td>
165 <td width="40%" align="right" valign="top"> Configuring transactions</td>
166 </tr>
167 </table>
168 </div>
169 </body>
170 </html>