Debian Codegraph @

docs/programmer_reference/transapp_atomicity.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>Atomicity</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="transapp.html" title="Chapter 11.  Berkeley DB Transactional Data Store Applications" />
11 <link rel="prev" href="transapp_put.html" title="Recoverability and deadlock handling" />
12 <link rel="next" href="transapp_inc.html" title="Isolation" />
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">Atomicity</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="transapp_put.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 11. 
26 Berkeley DB Transactional Data Store Applications
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="transapp_inc.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="transapp_atomicity"></a>Atomicity</h2>
38 </div>
39 </div>
40 </div>
41 <p>The second reason listed for using transactions was <span class="emphasis"><em>atomicity</em></span>.
42 Atomicity means that multiple operations can be grouped into a single
43 logical entity, that is, other threads of control accessing the database
44 will either see all of the changes or none of the changes. Atomicity
45 is important for applications wanting to update two related databases
46 (for example, a primary database and secondary index) in a single
47 logical action. Or, for an application wanting to update multiple
48 records in one database in a single logical action.</p>
49 <p>Any number of operations on any number of databases can be included in
50 a single transaction to ensure the atomicity of the operations. There
51 is, however, a trade-off between the number of operations included in
52 a single transaction and both throughput and the possibility of
53 deadlock. The reason for this is because transactions acquire locks
54 throughout their lifetime and do not release the locks until commit or
55 abort time. So, the more operations included in a transaction, the more
56 likely it is that a transaction will block other operations and that
57 deadlock will occur. However, each transaction commit requires a
58 synchronous disk I/O, so grouping multiple operations into a transaction
59 can increase overall throughput. (There is one exception to this: the
60 <a href="../api_reference/C/envset_flags.html#set_flags_DB_TXN_WRITE_NOSYNC" class="olink">DB_TXN_WRITE_NOSYNC</a> and <a href="../api_reference/C/envset_flags.html#envset_flags_DB_TXN_NOSYNC" class="olink">DB_TXN_NOSYNC</a> flags cause
61 transactions to exhibit the ACI (atomicity, consistency and isolation)
62 properties, but not D (durability); avoiding the write and/or
63 synchronous disk I/O on transaction commit greatly increases transaction
64 throughput for some applications.)</p>
65 <p>When applications do create complex transactions, they often avoid
66 having more than one complex transaction at a time because simple
67 operations like a single <a href="../api_reference/C/dbput.html" class="olink">DB-&gt;put()</a> are unlikely to deadlock with
68 each other or the complex transaction; while multiple complex
69 transactions are likely to deadlock with each other because they will
70 both acquire many locks over their lifetime. Alternatively, complex
71 transactions can be broken up into smaller sets of operations, and each
72 of those sets may be encapsulated in a nested transaction. Because
73 nested transactions may be individually aborted and retried without
74 causing the entire transaction to be aborted, this allows complex
75 transactions to proceed even in the face of heavy contention, repeatedly
76 trying the suboperations until they succeed.</p>
77 <p>It is also helpful to order operations within a transaction; that is,
78 access the databases and items within the databases in the same order,
79 to the extent possible, in all transactions. Accessing databases and
80 items in different orders greatly increases the likelihood of operations
81 being blocked and failing due to deadlocks.</p>
82 </div>
83 <div class="navfooter">
84 <hr />
85 <table width="100%" summary="Navigation footer">
86 <tr>
87 <td width="40%" align="left"><a accesskey="p" href="transapp_put.html">Prev</a> </td>
88 <td width="20%" align="center">
89 <a accesskey="u" href="transapp.html">Up</a>
90 </td>
91 <td width="40%" align="right"> <a accesskey="n" href="transapp_inc.html">Next</a></td>
92 </tr>
93 <tr>
94 <td width="40%" align="left" valign="top">Recoverability and deadlock handling </td>
95 <td width="20%" align="center">
96 <a accesskey="h" href="index.html">Home</a>
97 </td>
98 <td width="40%" align="right" valign="top"> Isolation</td>
99 </tr>
100 </table>
101 </div>
102 </body>
103 </html>