1<!--$Id: config.so,v 10.22 2008/04/23 14:50:45 margo Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB Reference Guide: Configuring locking</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<a name="2"><!--meow--></a>
12<table width="100%"><tr valign=top>
13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Locking Subsystem</dl></b></td>
14<td align=right><a href="../lock/intro.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../lock/max.html"><img src="../../images/next.gif" alt="Next"></a>
15</td></tr></table>
16<p align=center><b>Configuring locking</b></p>
17<p>The <a href="../../api_c/env_set_lk_detect.html">DB_ENV-&gt;set_lk_detect</a> method specifies that the deadlock detector
18should be run whenever a lock is about to block.  This option provides
19for rapid detection of deadlocks at the expense of potentially frequent
20invocations of the deadlock detector.  On a fast processor with a highly
21contentious application where response time is critical, this is a good
22choice.  An option argument to the <a href="../../api_c/env_set_lk_detect.html">DB_ENV-&gt;set_lk_detect</a> method
23indicates which lock requests should be rejected.</p>
24<p>The application can limit how long it blocks on a contested resource.
25The <a href="../../api_c/env_set_timeout.html">DB_ENV-&gt;set_timeout</a> method specifies the length of the timeout.
26This value is checked whenever deadlock detection is performed,
27so the accuracy of the timeout depends upon the frequency of
28deadlock detection.</p>
29<p>In general, when applications are not specifying lock and transaction
30timeout values, the <a href="../../api_c/env_set_lk_detect.html#DB_LOCK_DEFAULT">DB_LOCK_DEFAULT</a> option is probably the
31correct first choice, and other options should only be selected based
32on evidence that they improve transaction throughput.  If an application
33has long-running transactions, <a href="../../api_c/env_set_lk_detect.html#DB_LOCK_YOUNGEST">DB_LOCK_YOUNGEST</a> will guarantee
34that transactions eventually complete, but it may do so at the expense
35of a large number of lock request rejections (and therefore, transaction
36aborts).</p>
37<p>The alternative to using the <a href="../../api_c/env_set_lk_detect.html">DB_ENV-&gt;set_lk_detect</a> method is to
38explicitly perform deadlock detection using the Berkeley DB
39<a href="../../api_c/lock_detect.html">DB_ENV-&gt;lock_detect</a> method.</p>
40<p>The <a href="../../api_c/env_set_lk_conflicts.html">DB_ENV-&gt;set_lk_conflicts</a> method allows you to specify your own
41locking conflicts matrix.  This is an advanced configuration option,
42and is almost never necessary.</p>
43<table width="100%"><tr><td><br></td><td align=right><a href="../lock/intro.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../lock/max.html"><img src="../../images/next.gif" alt="Next"></a>
44</td></tr></table>
45<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
46</body>
47</html>
48