Debian Codegraph @

docs/gsg_txn/JAVA/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
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 <span>
78 <code class="methodname">DatabaseConfig.setNoWaitDbExclusiveLock()</code>
79 method on the <code class="classname">DatabaseConfig</code> object
80 that you use to configure the
81 <code class="classname">Database</code> handle which is to acquire
82 the exclusive lock. Setting a value of
83 <code class="literal">False</code> to this method means that the
84 handle open operation will block until it can obtain the
85 exclusive lock. A value of <code class="literal">False</code> means
86 that if the open operation cannot obtain the exclusive
87 lock immediately, it will throw a
88 <code class="classname">LockNotGrantedException</code> exception.
89 </span>
90 </p>
91 <p>
92 Once configured and opened, a handled configured with an
93 exclusive database lock will hold that lock until the handle
94 is closed.
95 </p>
96 </div>
97 <div class="navfooter">
98 <hr />
99 <table width="100%" summary="Navigation footer">
100 <tr>
101 <td width="40%" align="left"><a accesskey="p" href="txn_ccursor.html">Prev</a> </td>
102 <td width="20%" align="center">
103 <a accesskey="u" href="txnconcurrency.html">Up</a>
104 </td>
105 <td width="40%" align="right"> <a accesskey="n" href="readmodifywrite.html">Next</a></td>
106 </tr>
107 <tr>
108 <td width="40%" align="left" valign="top">Transactional Cursors and Concurrent Applications </td>
109 <td width="20%" align="center">
110 <a accesskey="h" href="index.html">Home</a>
111 </td>
112 <td width="40%" align="right" valign="top"> Read/Modify/Write</td>
113 </tr>
114 </table>
115 </div>
116 </body>
117 </html>