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