notxn.html   [plain text]


<!--$Id: notxn.so,v 10.15 2001/05/22 19:39:31 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Locking without transactions</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Locking Subsystem</dl></b></td>
<td align=right><a href="../lock/page.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../lock/twopl.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p align=center><b>Locking without transactions</b></p>
<p>If an application runs with locking specified, but not transactions (for
example, <a href="../../api_c/env_open.html">DB_ENV-&gt;open</a> is called with <a href="../../api_c/env_open.html#DB_INIT_LOCK">DB_INIT_LOCK</a> or
<a href="../../api_c/env_open.html#DB_INIT_CDB">DB_INIT_CDB</a> specified, but not <a href="../../api_c/env_open.html#DB_INIT_TXN">DB_INIT_TXN</a>), locks are
normally acquired during each Berkeley DB operation and released before the
operation returns to the caller.  The only exception is in the case of
cursor operations.  Cursors identify a particular position in a file.
For this reason, cursors must retain read locks across cursor calls to
make sure that the position is uniquely identifiable during a subsequent
cursor call, and so that an operation using <a href="../../api_c/dbc_get.html#DB_CURRENT">DB_CURRENT</a> will
always refer to the same record as a previous cursor call.  These cursor
locks cannot be released until the cursor is either repositioned and a
new cursor lock established (for example, using the <a href="../../api_c/dbc_get.html#DB_NEXT">DB_NEXT</a>
or <a href="../../api_c/dbc_get.html#DB_SET">DB_SET</a> flags), or the cursor is closed.  As a result,
application writers are encouraged to close cursors as soon as
possible.</p>
<p>It is important to realize that concurrent applications that use locking
must ensure that two concurrent threads do not block each other.
However, because Btree and Hash access method page splits can occur at
any time, there is virtually no way to guarantee that an application
that writes the database cannot deadlock.  Applications running without
the protection of transactions may deadlock, and can leave the database
in an inconsistent state when they do so.  Applications that need
concurrent access, but not transactions, are more safely implemented
using the Berkeley DB Concurrent Data Store Product.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../lock/page.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../lock/twopl.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>