Debian Codegraph @

docs/gsg_txn/C/exclusivelock.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>Exclusive Database Handles</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="txnconcurrency.html" title="Chapter 4. Concurrency" />
11 <link rel="prev" href="txn_ccursor.html" title="Transactional Cursors and Concurrent Applications" />
12 <link rel="next" href="readmodifywrite.html" title="Read/Modify/Write" />
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">Exclusive Database Handles</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="txn_ccursor.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 4. Concurrency</th>
26 <td width="20%" align="right"> <a accesskey="n" href="readmodifywrite.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="exclusivelock"></a>Exclusive Database Handles</h2>
36 </div>
37 </div>
38 </div>
39 <p>
40 In some cases, concurrent applications can benefit from
41 occasionally granting exclusive access to the entire
42 database to a single database handle. This is
43 desirable when a thread will perform an operation that
44 touches all or most of the pages in a database.
45 </p>
46 <p>
47 To configure a handle to have exclusive access to a database,
48 you give it a single write lock to the entire database. This
49 causes all other threads to block when they attempt to gain a
50 read or write lock to any part of that database.
51 </p>
52 <p>
53 The exclusive lock allows for improved throughput
54 because the handle will not attempt to acquire any further
55 locks once it has the exclusive write lock. It will also never
56 be blocked waiting for a lock, and there is no possibility of
57 a deadlock/retry cycle.
58 </p>
59 <p>
60 Note that an exclusive database handle can only have one
61 transaction active for it at a time.
62 </p>
63 <p>
64 To configure a database handle with an exclusive lock, you
65 use the
66 <span>
67 <code class="methodname">DB-&gt;set_lk_exclusive()</code>
68
69 method before you open the database handle. Setting a
70 value of <code class="literal">0</code> to this method means that
71 the handle open operation will block until it can obtain
72 the exclusive lock. A non-zero value means that if the
73 method cannot obtain the exclusive lock immediately when
74 the handle is opened, the open operation will exit with a
75 <code class="literal">DB_LOCK_NOTGRANTED</code> error return.
76 </span>
77
78 </p>
79 <p>
80 Once configured and opened, a handled configured with an
81 exclusive database lock will hold that lock until the handle
82 is closed.
83 </p>
84 </div>
85 <div class="navfooter">
86 <hr />
87 <table width="100%" summary="Navigation footer">
88 <tr>
89 <td width="40%" align="left"><a accesskey="p" href="txn_ccursor.html">Prev</a> </td>
90 <td width="20%" align="center">
91 <a accesskey="u" href="txnconcurrency.html">Up</a>
92 </td>
93 <td width="40%" align="right"> <a accesskey="n" href="readmodifywrite.html">Next</a></td>
94 </tr>
95 <tr>
96 <td width="40%" align="left" valign="top">Transactional Cursors and Concurrent Applications </td>
97 <td width="20%" align="center">
98 <a accesskey="h" href="index.html">Home</a>
99 </td>
100 <td width="40%" align="right" valign="top"> Read/Modify/Write</td>
101 </tr>
102 </table>
103 </div>
104 </body>
105 </html>