Debian Codegraph @

docs/gsg_txn/C/apireq.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>Application Requirements</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="introduction.html" title="Chapter 1. Introduction" />
11 <link rel="prev" href="sysfailure.html" title="A Note on System Failure" />
12 <link rel="next" href="multithread-intro.html" title="Multi-threaded and Multi-process Applications" />
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">Application Requirements</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="sysfailure.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 1. Introduction</th>
26 <td width="20%" align="right"> <a accesskey="n" href="multithread-intro.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="apireq"></a>Application Requirements</h2>
36 </div>
37 </div>
38 </div>
39 <p>
40 In order to use transactions, your application has certain
41 requirements beyond what is required of non-transactional protected
42 applications. They are:
43 </p>
44 <div class="itemizedlist">
45 <ul type="disc">
46 <li>
47 <p>
48 Environments.
49 </p>
50 <p>
51 Environments are optional for non-transactional
52 applications, but they are required for transactional
53 applications.
54 </p>
55 <p>
56 Environment usage is described in detail in
57 <a class="xref" href="usingtxns.html" title="Chapter 3. Transaction Basics">Transaction Basics</a>.
58 </p>
59 </li>
60 <li>
61 <p>
62 Transaction subsystem.
63 </p>
64 <p>
65 In order to use transactions, you must explicitly
66 enable the transactional subsystem for your
67 application, and this must be done at the time that
68 your environment is first created.
69 </p>
70 </li>
71 <li>
72 <p>
73 Logging subsystem.
74 </p>
75 <p>
76 The logging subsystem is required for recovery purposes, but
77 its usage also means your application may require a
78 little more administrative effort than it does when logging
79 is not in use. See <a class="xref" href="filemanagement.html" title="Chapter 5. Managing DB Files">Managing DB Files</a> for more information.
80 </p>
81 </li>
82 <li>
83 <p>
84 <span>DB_TXN</span>
85
86
87
88 handles.
89 </p>
90 <p>
91 In order to obtain the atomicity guarantee offered by
92 the transactional subsystem (that is, combine multiple
93 operations in a single unit of work), your application must use
94 transaction handles. These handles are obtained from your
95 <span>DB_ENV</span>
96
97
98
99 objects. They should normally be short-lived, and their usage is
100 reasonably simple. To complete a transaction and save
101 the work it performed, you
102 call its <code class="methodname">commit()</code> method. To
103 complete a transaction and discard its work, you call its
104 <code class="methodname">abort()</code> method.
105 </p>
106 <p>
107 In addition, it is possible to use auto commit if you want
108 to transactional protect a single write operation. Auto
109 commit allows a transaction to be used without
110 obtaining an explicit transaction handle. See
111 <a class="xref" href="autocommit.html" title="Auto Commit">Auto Commit</a>
112 for information on how to use auto commit.
113 </p>
114 </li>
115 <li>
116 <p>
117 Database open requirements.
118 </p>
119 <p>
120
121 <span>In addition to using
122 environments and initializing the
123 correct subsystems, your</span>
124
125
126 application must transaction protect the database
127
128 opens<span>,
129 and any secondary index associations,</span>
130
131 if subsequent operations on the databases are to be transaction
132 protected. The database open and secondary index
133 association are commonly transaction protected using
134 auto commit.
135 </p>
136 </li>
137 <li>
138 <p>
139 Deadlock detection.
140 </p>
141 <p>
142 Typically transactional applications use multiple
143 threads of control when accessing the database.
144 Any time multiple threads are used on a single resource,
145 the potential for lock contention arises. In turn, lock
146 contention can lead to deadlocks. See
147 <a class="xref" href="blocking_deadlocks.html" title="Locks, Blocks, and Deadlocks">Locks, Blocks, and Deadlocks</a>
148 for more information.
149 </p>
150 <p>
151 Therefore, transactional applications must frequently
152 include code for detecting and responding to deadlocks.
153 Note that this requirement is not
154 <span class="emphasis"><em>specific</em></span> to transactions
155 – you can certainly write concurrent
156 non-transactional DB applications. Further, not
157 every transactional application uses concurrency and
158 so not every transactional application must
159 manage deadlocks. Still, deadlock management is so
160 frequently a characteristic of transactional
161 applications that we discuss it in this
162 book. See <a class="xref" href="txnconcurrency.html" title="Chapter 4. Concurrency">Concurrency</a>
163 for more information.
164 </p>
165 </li>
166 </ul>
167 </div>
168 </div>
169 <div class="navfooter">
170 <hr />
171 <table width="100%" summary="Navigation footer">
172 <tr>
173 <td width="40%" align="left"><a accesskey="p" href="sysfailure.html">Prev</a> </td>
174 <td width="20%" align="center">
175 <a accesskey="u" href="introduction.html">Up</a>
176 </td>
177 <td width="40%" align="right"> <a accesskey="n" href="multithread-intro.html">Next</a></td>
178 </tr>
179 <tr>
180 <td width="40%" align="left" valign="top">A Note on System Failure </td>
181 <td width="20%" align="center">
182 <a accesskey="h" href="index.html">Home</a>
183 </td>
184 <td width="40%" align="right" valign="top"> Multi-threaded
185 <span>and Multi-process</span>
186 Applications</td>
187 </tr>
188 </table>
189 </div>
190 </body>
191 </html>