2
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
4
<!--See the file LICENSE for redistribution information.-->
7
<title>Berkeley DB Reference Guide: Introduction</title>
8
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
12
<a name="2"><!--meow--></a><a name="3"><!--meow--></a>
13
<table width="100%"><tr valign=top>
14
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Distributed Transactions</dl></h3></td>
15
<td align=right><a href="../../ref/rep/ex_rq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/xa/build.html"><img src="../../images/next.gif" alt="Next"></a>
18
<h1 align=center>Introduction</h1>
19
<p>Berkeley DB provides support for distributed transactions using a two-phase
20
commit protocol via its <a href="../../api_c/txn_prepare.html">DB_TXN->prepare</a> and <a href="../../api_c/txn_recover.html">DB_ENV->txn_recover</a>
21
interfaces. The <a href="../../api_c/txn_prepare.html">DB_TXN->prepare</a> method performs the first phase of a
22
two-phase commit, flushing the log to disk, and associating a global
23
transaction ID with the underlying Berkeley DB transaction. This global
24
transaction ID should be used by the global transaction manager to
25
identify the Berkeley DB transaction, and will be returned by the
26
<a href="../../api_c/txn_recover.html">DB_ENV->txn_recover</a> method when it is called during recovery.
27
<p>Distributed transactions are necessary whenever an application wants to
28
transaction-protect data in multiple Berkeley DB environments, even if those
29
environments are on the same machine. However, Berkeley DB does not perform
30
distributed deadlock detection, therefore it is the responsibility of
31
the application to ensure that accesses in different environments cannot
32
deadlock (this can be accomplished through careful ordering of
33
operations to the multiple environments), or by using the
34
<a href="../../api_c/lock_vec.html#DB_LOCK_NOWAIT">DB_LOCK_NOWAIT</a> option and eventually abort transactions that
35
have been waiting "too long" (where "too long" is determined by an
36
application-specific timeout).
37
<p>In order to use the two-phase commit feature of Berkeley DB, an application
38
must either implement its own global transaction manager or use an
39
XA-compliant transaction manager (as Berkeley DB can act as an XA-compliant
41
<p>When using distributed transactions, there is no way to perform
42
hot backups of multiple environments and guarantee that the backups
43
are global-transaction-consistent across these multiple environments.
44
If backups are desired, then all write transactions should be suspended;
45
that is, active write transactions must be allowed to complete and no
46
new write transactions should be begun. Once there are no active write
47
transactions, the logs may be copied for backup purposes and the backup
48
will be consistent across the multiple environments.
49
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/ex_rq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/xa/build.html"><img src="../../images/next.gif" alt="Next"></a>
51
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>