Debian Codegraph @

docs/gsg_txn/C/txnnowait.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>No Wait on Blocks</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="readmodifywrite.html" title="Read/Modify/Write" />
12 <link rel="next" href="reversesplit.html" title="Reverse BTree Splits" />
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">No Wait on Blocks</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="readmodifywrite.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 4. Concurrency</th>
26 <td width="20%" align="right"> <a accesskey="n" href="reversesplit.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="txnnowait"></a>No Wait on Blocks</h2>
36 </div>
37 </div>
38 </div>
39 <p>
40 Normally when a DB transaction is blocked on a lock request, it
41 must wait until the requested lock becomes available before its
42 thread-of-control can proceed. However, it is possible to configure a
43 transaction handle such that it will report a deadlock rather
44 than wait for the block to clear.
45 </p>
46 <p>
47 You do this on a transaction by transaction basis by specifying
48
49 <span>
50 <code class="literal">DB_TXN_NOWAIT</code>
51 to the
52 <code class="methodname">DB_ENV-&gt;txn_begin()</code>
53
54
55 method.
56 </span>
57
58
59 </p>
60 <p>
61 For example:
62 </p>
63 <pre class="programlisting"> /* Get the transaction */
64 DB_TXN *txn = NULL;
65 ret = envp-&gt;txn_begin(envp, NULL, &amp;txn, DB_TXN_NOWAIT);
66 if (ret != 0) {
67 envp-&gt;err(envp, ret, "txn_begin failed");
68 return (EXIT_FAILURE);
69 }
70 ....
71 /* Deadlock detection and exception handling omitted for brevity. */</pre>
72 </div>
73 <div class="navfooter">
74 <hr />
75 <table width="100%" summary="Navigation footer">
76 <tr>
77 <td width="40%" align="left"><a accesskey="p" href="readmodifywrite.html">Prev</a> </td>
78 <td width="20%" align="center">
79 <a accesskey="u" href="txnconcurrency.html">Up</a>
80 </td>
81 <td width="40%" align="right"> <a accesskey="n" href="reversesplit.html">Next</a></td>
82 </tr>
83 <tr>
84 <td width="40%" align="left" valign="top">Read/Modify/Write </td>
85 <td width="20%" align="center">
86 <a accesskey="h" href="index.html">Home</a>
87 </td>
88 <td width="40%" align="right" valign="top"> Reverse BTree Splits</td>
89 </tr>
90 </table>
91 </div>
92 </body>
93 </html>