intro.html   [plain text]


<!--$Id: intro.so,v 10.7 2006/11/13 18:05:06 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Introduction to distributed 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><a name="3"><!--meow--></a>
<table width="100%"><tr valign=top>
<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Distributed Transactions</dl></b></td>
<td align=right><a href="../rep/ex_rq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../xa/build.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p align=center><b>Introduction to distributed transactions</b></p>
<p>Berkeley DB provides support for distributed transactions using a two-phase
commit protocol via its <a href="../../api_c/txn_prepare.html">DB_TXN-&gt;prepare</a> and <a href="../../api_c/txn_recover.html">DB_ENV-&gt;txn_recover</a>
interfaces.  The <a href="../../api_c/txn_prepare.html">DB_TXN-&gt;prepare</a> method performs the first phase of a
two-phase commit, flushing the log to disk, and associating a global
transaction ID with the underlying Berkeley DB transaction.  This global
transaction ID should be used by the global transaction manager to
identify the Berkeley DB transaction, and will be returned by the
<a href="../../api_c/txn_recover.html">DB_ENV-&gt;txn_recover</a> method when it is called during recovery.</p>
<p>Distributed transactions are necessary whenever an application wants to
transaction-protect data in multiple Berkeley DB environments, even if those
environments are on the same machine.  However, Berkeley DB does not perform
distributed deadlock detection, therefore it is the responsibility of
the application to ensure that accesses in different environments cannot
deadlock (this can be accomplished through careful ordering of
operations to the multiple environments), or by using the
<a href="../../api_c/lock_vec.html#DB_LOCK_NOWAIT">DB_LOCK_NOWAIT</a> option and eventually abort transactions that
have been waiting "too long" (where "too long" is determined by an
application-specific timeout).</p>
<p>In order to use the two-phase commit feature of Berkeley DB, an application
must either implement its own global transaction manager or use an
XA-compliant transaction manager (as Berkeley DB can act as an XA-compliant
resource manager).</p>
<p>When using distributed transactions, there is no way to perform
hot backups of multiple environments and guarantee that the backups
are global-transaction-consistent across these multiple environments.
If backups are desired, then all write transactions should be suspended;
that is, active write transactions must be allowed to complete and no
new write transactions should be begun.  Once there are no active write
transactions, the logs may be copied for backup purposes and the backup
will be consistent across the multiple environments.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../rep/ex_rq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../xa/build.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>