1
<!--$Id: filesys.so,v 10.33 2001/05/05 01:49:28 bostic Exp $-->
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
6
<title>Berkeley DB Reference Guide: Recovery and filesystem operations</title>
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
11
<a name="2"><!--meow--></a>
12
<table width="100%"><tr valign=top>
13
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Transactional Data Store Applications</dl></h3></td>
14
<td align=right><a href="../../ref/transapp/recovery.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/transapp/reclimit.html"><img src="../../images/next.gif" alt="Next"></a>
17
<h1 align=center>Recovery and filesystem operations</h1>
18
<p>When running in a transaction-protected environment, database creation
19
and deletion are logged as standalone transactions internal to Berkeley DB.
20
That is, for each such operation, a new transaction is begun and aborted
21
or committed internally, so that they will be recovered during recovery.
22
<p>The Berkeley DB API supports removing and renaming files. Renaming files is
23
supported by the <a href="../../api_c/db_rename.html">DB->rename</a> method, and removing files is
24
supported by the <a href="../../api_c/db_remove.html">DB->remove</a> method. Berkeley DB does not permit
25
specifying the <a href="../../api_c/db_open.html#DB_TRUNCATE">DB_TRUNCATE</a> flag when opening a file in a
26
transaction-protected environment. This is an implicit file deletion,
27
but one that does not always require the same operating system file
28
permissions as deleting and creating a file do.
29
<p>If you have changed the name of a file or deleted it outside of the
30
Berkeley DB library (for example, you explicitly removed a file using your
31
normal operating system utilities), then it is possible that recovery
32
will not be able to find a database to which the log refers. In this
33
case, <a href="../../utility/db_recover.html">db_recover</a> will produce a warning message, saying it was
34
unable to locate a file it expected to find. This message is only a
35
warning because the file may have been subsequently deleted as part of
36
normal database operations before the failure occurred, so is not
37
necessarily a problem.
38
<p>Generally, any filesystem operations that are performed outside the
39
Berkeley DB interface should be performed at the same time as making a
40
snapshot of the database. To perform filesystem operations correctly,
43
<p><li>Cleanly shut down database operations.
44
<p>To shut down database operations cleanly, all applications accessing
45
the database environment must be shut down and a transaction checkpoint
46
must be taken. If the applications are not implemented so they can be
47
shut down gracefully (that is, closing all references to the database
48
environment), recovery must be performed after all applications have
49
been killed to ensure that the underlying databases are consistent on
51
<p><li>Perform the filesystem operations; for example, remove or rename one or
53
<p><li>Make an archival snapshot of the database.
54
<p>Although this step is not strictly necessary, it is strongly
55
recommended. If this step is not performed, recovery from catastrophic
56
failure will require that recovery first be performed up to the time of
57
the filesystem operations, the filesystem operations be redone, and then
58
recovery be performed from the filesystem operations forward.
59
<p><li>Restart the database applications.
61
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/transapp/recovery.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/transapp/reclimit.html"><img src="../../images/next.gif" alt="Next"></a>
63
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>