Debian Codegraph @

docs/api_reference/CXX/dbset_lk_exclusive.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>Db::set_lk_exclusive()</title>
7 <link rel="stylesheet" href="apiReference.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 C++ API Reference" />
10 <link rel="up" href="db.html" title="Chapter 2.  The Db Handle" />
11 <link rel="prev" href="dbset_heap_regionsize.html" title="Db::set_heap_regionsize()" />
12 <link rel="next" href="dbset_lorder.html" title="Db::set_lorder()" />
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">Db::set_lk_exclusive()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbset_heap_regionsize.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 2. 
26 The Db Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="dbset_lorder.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="dbset_lk_exclusive"></a>Db::set_lk_exclusive()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 Db::set_lk_exclusive(int nowait_onoff); </pre>
45 <p>
46 Configures the database handle to obtain a write lock on the
47 entire database when it is opened. This gives the handle
48 exclusive access to the database, because the write lock will block
49 all other threads of control for both read and write access.
50 </p>
51 <p>
52 Use this method to improve the throughput performance on your
53 database for the thread that is controlling this handle. When
54 configured with this method, operations on the database do not
55 acquire page locks as they perform read and/or write operations.
56 Also, the exclusive lock means that operations performed on the
57 database handle will never be blocked waiting for lock due to
58 another thread's activities. The application will also be immune to
59 deadlocks.
60 </p>
61 <p>
62 On the other hand, use of this method means that you can only
63 have a single thread accessing the database until the handle is
64 closed. For some applications, the loss of multiple threads
65 concurrently operating on the database will result in
66 performance degradation.
67 </p>
68 <p>
69 Also, use of this method means that you can only have one
70 transaction active for the handle at a time.
71 </p>
72 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
73 <h3 class="title">Note</h3>
74 <p>
75 This method is incompatible with the
76 <a class="link" href="dbopen.html#open_DB_THREAD">DB_THREAD</a> configuration
77 flag.
78 </p>
79 </div>
80 <p>
81 The <code class="methodname">Db::set_lk_exclusive()</code> method may
82 not be called after the
83 <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> method is called.
84 </p>
85 <p>
86 The <code class="methodname">Db::set_lk_exclusive()</code> <span>
87
88 <span>
89 method either returns a non-zero error value or throws an
90 exception that encapsulates a non-zero error value on
91 failure, and returns 0 on success.
92 </span>
93 </span>
94 </p>
95 <div class="sect2" lang="en" xml:lang="en">
96 <div class="titlepage">
97 <div>
98 <div>
99 <h3 class="title"><a id="lk_exclusive_rep_notes"></a>Replication Notes</h3>
100 </div>
101 </div>
102 </div>
103 <p>
104 Replication applications that use exclusive database handles
105 need to be written with caution. This is because replication
106 clients cannot process updates on an exclusive database until
107 all local handles on the database are closed. Also, attempting
108 to open an exclusive database handle on a currently operating
109 client will result in the open call failing with the error
110 <code class="literal">EINVAL</code>.
111 </p>
112 <p>
113 Also, opening an exclusive database handle on a replication
114 master will result in all clients being locked out of the
115 database. On clients, existing handles on the exclusive
116 database will return the error
117 <code class="literal">DB_REP_DEAD_HANDLE</code> when accessed, and must
118 be closed. New handles opened on the exclusive database will
119 block until the master closes its exclusive database handle.
120 </p>
121 </div>
122 <div class="sect2" lang="en" xml:lang="en">
123 <div class="titlepage">
124 <div>
125 <div>
126 <h3 class="title"><a id="idp5671608"></a>Parameters</h3>
127 </div>
128 </div>
129 </div>
130 <div class="sect3" lang="en" xml:lang="en">
131 <div class="titlepage">
132 <div>
133 <div>
134 <h4 class="title"><a id="idp5670320"></a>nowait_onoff</h4>
135 </div>
136 </div>
137 </div>
138 <p>
139 If set to <code class="literal">0</code>, this method will block
140 until it can obtain the exclusive lock on the database. If
141 set to some value other than <code class="literal">0</code>,
142 <code class="literal">DB_LOCK_NOTGRANTED</code> is returned when the
143 handle is opened if the exclusive database lock cannot be
144 immediately obtained.
145 </p>
146 </div>
147 </div>
148 <div class="sect2" lang="en" xml:lang="en">
149 <div class="titlepage">
150 <div>
151 <div>
152 <h3 class="title"><a id="idp5667408"></a>Errors</h3>
153 </div>
154 </div>
155 </div>
156 <p>
157 The <code class="methodname">Db::set_lk_exclusive()</code> <span>
158
159 <span>
160 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
161 exception, encapsulating one of the following non-zero errors, or return one
162 of the following non-zero errors:
163 </span>
164 </span>
165 </p>
166 <div class="sect3" lang="en" xml:lang="en">
167 <div class="titlepage">
168 <div>
169 <div>
170 <h4 class="title"><a id="idp5688824"></a>EINVAL</h4>
171 </div>
172 </div>
173 </div>
174 <p>
175 If the method was called after
176 <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a>
177 was called; the method was called on a currently operating
178 replication client; or if an invalid flag value or
179 parameter was specified.
180 </p>
181 </div>
182 </div>
183 <div class="sect2" lang="en" xml:lang="en">
184 <div class="titlepage">
185 <div>
186 <div>
187 <h3 class="title"><a id="idp5673712"></a>Class</h3>
188 </div>
189 </div>
190 </div>
191 <p>
192 <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
193 </p>
194 </div>
195 <div class="sect2" lang="en" xml:lang="en">
196 <div class="titlepage">
197 <div>
198 <div>
199 <h3 class="title"><a id="idp5668848"></a>See Also</h3>
200 </div>
201 </div>
202 </div>
203 <p>
204 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
205 </p>
206 </div>
207 </div>
208 <div class="navfooter">
209 <hr />
210 <table width="100%" summary="Navigation footer">
211 <tr>
212 <td width="40%" align="left"><a accesskey="p" href="dbset_heap_regionsize.html">Prev</a> </td>
213 <td width="20%" align="center">
214 <a accesskey="u" href="db.html">Up</a>
215 </td>
216 <td width="40%" align="right"> <a accesskey="n" href="dbset_lorder.html">Next</a></td>
217 </tr>
218 <tr>
219 <td width="40%" align="left" valign="top">Db::set_heap_regionsize() </td>
220 <td width="20%" align="center">
221 <a accesskey="h" href="index.html">Home</a>
222 </td>
223 <td width="40%" align="right" valign="top"> Db::set_lorder()</td>
224 </tr>
225 </table>
226 </div>
227 </body>
228 </html>