mirror of
https://github.com/berkeleydb/libdb.git
synced 2024-11-16 09:06:25 +00:00
522 lines
21 KiB
HTML
522 lines
21 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||
<title>Reviewing Berkeley DB log files</title>
|
||
<link rel="stylesheet" href="gettingStarted.css" type="text/css" />
|
||
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
|
||
<link rel="start" href="index.html" title="Berkeley DB Installation and Build Guide" />
|
||
<link rel="up" href="debug.html" title="Chapter 3. Debugging Applications" />
|
||
<link rel="prev" href="debug_runtime.html" title="Run-time error information" />
|
||
<link rel="next" href="build_android_intro.html" title="Chapter 4. Building Berkeley DB for Android" />
|
||
</head>
|
||
<body>
|
||
<div xmlns="" class="navheader">
|
||
<div class="libver">
|
||
<p>Library Version 11.2.5.3</p>
|
||
</div>
|
||
<table width="100%" summary="Navigation header">
|
||
<tr>
|
||
<th colspan="3" align="center">Reviewing Berkeley DB log files</th>
|
||
</tr>
|
||
<tr>
|
||
<td width="20%" align="left"><a accesskey="p" href="debug_runtime.html">Prev</a> </td>
|
||
<th width="60%" align="center">Chapter 3.
|
||
Debugging Applications
|
||
</th>
|
||
<td width="20%" align="right"> <a accesskey="n" href="build_android_intro.html">Next</a></td>
|
||
</tr>
|
||
</table>
|
||
<hr />
|
||
</div>
|
||
<div class="sect1" lang="en" xml:lang="en">
|
||
<div class="titlepage">
|
||
<div>
|
||
<div>
|
||
<h2 class="title" style="clear: both"><a id="debug_printlog"></a>Reviewing Berkeley DB log files</h2>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="toc">
|
||
<dl>
|
||
<dt>
|
||
<span class="sect2">
|
||
<a href="debug_printlog.html#idm1304224">Augmenting the Log for Debugging</a>
|
||
</span>
|
||
</dt>
|
||
<dt>
|
||
<span class="sect2">
|
||
<a href="debug_printlog.html#idm1194048">Extracting Committed Transactions and Transaction Status</a>
|
||
</span>
|
||
</dt>
|
||
<dt>
|
||
<span class="sect2">
|
||
<a href="debug_printlog.html#idm1341784">Extracting Transaction Histories</a>
|
||
</span>
|
||
</dt>
|
||
<dt>
|
||
<span class="sect2">
|
||
<a href="debug_printlog.html#idm986800">Extracting File Histories</a>
|
||
</span>
|
||
</dt>
|
||
<dt>
|
||
<span class="sect2">
|
||
<a href="debug_printlog.html#idm1437640">Extracting Page Histories</a>
|
||
</span>
|
||
</dt>
|
||
<dt>
|
||
<span class="sect2">
|
||
<a href="debug_printlog.html#idm680600">Other log processing tools</a>
|
||
</span>
|
||
</dt>
|
||
</dl>
|
||
</div>
|
||
<p>
|
||
If you are running with transactions and logging, the <a href="../api_reference/C/db_printlog.html" class="olink">db_printlog</a> utility can
|
||
be a useful debugging aid. The <a href="../api_reference/C/db_printlog.html" class="olink">db_printlog</a> utility will display the contents
|
||
of your log files in a human readable (and machine-readable) format.
|
||
</p>
|
||
<p>
|
||
The <a href="../api_reference/C/db_printlog.html" class="olink">db_printlog</a> utility will attempt to display any and all log files present
|
||
in a designated db_home directory. For each log record, the
|
||
<a href="../api_reference/C/db_printlog.html" class="olink">db_printlog</a> utility will display a line of the form:
|
||
</p>
|
||
<pre class="programlisting">
|
||
[22][28]db_big: rec: 43 txnid 80000963 prevlsn [21][10483281]
|
||
</pre>
|
||
<p>
|
||
The opening numbers in square brackets are the <span class="emphasis"><em>log sequence
|
||
number</em></span> (<span class="emphasis"><em>LSN</em></span>) of the log record
|
||
being displayed. The first number indicates the log file in which the
|
||
record appears, and the second number indicates the offset in that file
|
||
of the record.
|
||
</p>
|
||
<p>
|
||
The first character string identifies the particular log operation
|
||
being reported. The log records corresponding to particular operations
|
||
are described following. The rest of the line consists of name/value
|
||
pairs.
|
||
</p>
|
||
<p>
|
||
The rec field indicates the record type (this is used to dispatch
|
||
records in the log to appropriate recovery functions).
|
||
</p>
|
||
<p>
|
||
The txnid field identifies the transaction for which this record was
|
||
written. A txnid of 0 means that the record was written outside the
|
||
context of any transaction. You will see these most frequently for
|
||
checkpoints.
|
||
</p>
|
||
<p>
|
||
Finally, the prevlsn contains the LSN of the last record for this
|
||
transaction. By following prevlsn fields, you can accumulate all the
|
||
updates for a particular transaction. During normal abort processing,
|
||
this field is used to quickly access all the records for a particular
|
||
transaction.
|
||
</p>
|
||
<p>
|
||
After the initial line identifying the record type, each field of the
|
||
log record is displayed, one item per line. There are several fields
|
||
that appear in many different records and a few fields that appear only
|
||
in some records.
|
||
</p>
|
||
<p>
|
||
The following table presents each currently written log record type
|
||
with a brief description of the operation it describes. Any of these
|
||
record types may have the string "_debug" appended if they were written
|
||
because <a href="../api_reference/C/dbset_flags.html#dbset_flags_DB_TXN_NOT_DURABLE" class="olink">DB_TXN_NOT_DURABLE</a> was specified and the
|
||
system was configured with
|
||
<a class="link" href="build_unix_conf.html#build_unix_conf.--enable-diagnostic">--enable-diagnostic</a>.
|
||
</p>
|
||
<div class="informaltable">
|
||
<table border="1" width="80%">
|
||
<colgroup>
|
||
<col />
|
||
<col />
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th>Log Record Type</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>bam_adj</td>
|
||
<td>Used when we insert/remove an index into/from the page header of a Btree page.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_cadjust</td>
|
||
<td>Keeps track of record counts in a Btree or Recno database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_cdel</td>
|
||
<td>Used to mark a record on a page as deleted.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_curadj</td>
|
||
<td>Used to adjust a cursor location when a nearby record changes in a Btree database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_merge</td>
|
||
<td>Used to merge two Btree database pages during compaction.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_pgno</td>
|
||
<td>Used to replace a page number in a Btree record.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_rcuradj</td>
|
||
<td>Used to adjust a cursor location when a nearby record changes in a Recno database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_relink</td>
|
||
<td>Fix leaf page prev/next chain when a page is removed.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_repl</td>
|
||
<td>Describes a replace operation on a record.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_root</td>
|
||
<td>Describes an assignment of a root page.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_rsplit</td>
|
||
<td>Describes a reverse page split.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>bam_split</td>
|
||
<td>Describes a page split.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>crdel_inmem_create</td>
|
||
<td>Record the creation of an in-memory named database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>crdel_inmem_remove</td>
|
||
<td>Record the removal of an in-memory named database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>crdel_inmem_rename</td>
|
||
<td>Record the rename of an in-memory named database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>crdel_metasub</td>
|
||
<td>Describes the creation of a metadata page for a subdatabase.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_addrem</td>
|
||
<td>Add or remove an item from a page of duplicates.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_big</td>
|
||
<td>Add an item to an overflow page (<span class="emphasis"><em>overflow pages</em></span> contain items too large to place on the main page)</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_cksum</td>
|
||
<td>Unable to checksum a page.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_debug</td>
|
||
<td>Log debugging message.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_noop</td>
|
||
<td>This marks an operation that did nothing but update the LSN on a page.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_ovref</td>
|
||
<td>Increment or decrement the reference count for a big item.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_pg_alloc</td>
|
||
<td>Indicates we allocated a page to a database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_pg_free</td>
|
||
<td>Indicates we freed a page (freed pages are added to a freelist and reused).</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_pg_freedata</td>
|
||
<td>Indicates we freed a page that still contained data entries (freed pages are added to a freelist and reused.)</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_pg_init</td>
|
||
<td>Indicates we reinitialized a page during a truncate.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>db_pg_sort</td>
|
||
<td>Sort the free page list and free pages at the end of the file.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>dbreg_register</td>
|
||
<td>Records an open of a file (mapping the filename to a log-id that is used in subsequent log operations).</td>
|
||
</tr>
|
||
<tr>
|
||
<td>fop_create</td>
|
||
<td>Create a file in the file system.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>fop_file_remove</td>
|
||
<td>Remove a name in the file system.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>fop_remove</td>
|
||
<td>Remove a file in the file system.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>fop_rename</td>
|
||
<td>Rename a file in the file system.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>fop_write</td>
|
||
<td>Write bytes to an object in the file system.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_chgpg</td>
|
||
<td>Used to adjust a cursor location when a Hash page is removed, and its elements are moved to a different Hash page.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_copypage</td>
|
||
<td>Used when we empty a bucket page, but there are overflow pages for the bucket; one needs to be copied back into the actual bucket.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_curadj</td>
|
||
<td>Used to adjust a cursor location when a nearby record changes in a Hash database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_groupalloc</td>
|
||
<td>Allocate some number of contiguous pages to the Hash database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_insdel</td>
|
||
<td>Insert/delete an item on a Hash page.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_metagroup</td>
|
||
<td>Update the metadata page to reflect the allocation of a sequence of contiguous pages.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_newpage</td>
|
||
<td>Adds or removes overflow pages from a Hash bucket.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_replace</td>
|
||
<td>Handle updates to records that are on the main page.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ham_splitdata</td>
|
||
<td>Record the page data for a split.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>heap_addrem</td>
|
||
<td>Add or remove an entry from a Heap database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>heap_pg_alloc</td>
|
||
<td>Indicates we allocated a page to a Heap database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>heap_trunc_meta</td>
|
||
<td>Records the truncation of the meta page in a Heap
|
||
database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>heap_trunc_page</td>
|
||
<td>Records the truncation of a data page in a Heap
|
||
database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>qam_add</td>
|
||
<td>Describes the actual addition of a new record to a Queue.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>qam_del</td>
|
||
<td>Delete a record in a Queue.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>qam_delext</td>
|
||
<td>Delete a record in a Queue with extents.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>qam_incfirst</td>
|
||
<td>Increments the record number that refers to the first record in the database.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>qam_mvptr</td>
|
||
<td>Indicates we changed the reference to either or both of the first and current records in the file.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>txn_child</td>
|
||
<td>Commit a child transaction.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>txn_ckp</td>
|
||
<td>Transaction checkpoint.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>txn_recycle</td>
|
||
<td>Transaction IDs wrapped.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>txn_regop</td>
|
||
<td>Logs a regular (non-child) transaction commit.</td>
|
||
</tr>
|
||
<tr>
|
||
<td>txn_xa_regop</td>
|
||
<td>Logs a prepare message.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div class="sect2" lang="en" xml:lang="en">
|
||
<div class="titlepage">
|
||
<div>
|
||
<div>
|
||
<h3 class="title"><a id="idm1304224"></a>Augmenting the Log for Debugging</h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<p>
|
||
When debugging applications, it is sometimes useful to log not only
|
||
the actual operations that modify pages, but also the underlying
|
||
Berkeley DB functions being executed. This form of logging can add
|
||
significant bulk to your log, but can permit debugging application
|
||
errors that are almost impossible to find any other way. To turn
|
||
on these log messages, specify the --enable-debug_rop and
|
||
--enable-debug_wop configuration options when
|
||
configuring Berkeley DB. See
|
||
<a class="xref" href="build_unix_conf.html" title="Configuring Berkeley DB">Configuring Berkeley DB</a> for more information.
|
||
</p>
|
||
</div>
|
||
<div class="sect2" lang="en" xml:lang="en">
|
||
<div class="titlepage">
|
||
<div>
|
||
<div>
|
||
<h3 class="title"><a id="idm1194048"></a>Extracting Committed Transactions and Transaction Status</h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<p>
|
||
Sometimes, it is helpful to use the human-readable log output to
|
||
determine which transactions committed and aborted. The awk
|
||
script, commit.awk, (found in the db_printlog directory of the
|
||
Berkeley DB distribution) allows you to do just that. The
|
||
following command, where log_output is the output of db_printlog,
|
||
will display a list of the transaction IDs of all committed
|
||
transactions found in the log:
|
||
</p>
|
||
<pre class="programlisting">awk -f commit.awk log_output</pre>
|
||
<p>
|
||
If you need a complete list of both committed and aborted transactions,
|
||
then the script status.awk will produce it. The syntax is as
|
||
follows:
|
||
</p>
|
||
<pre class="programlisting">awk -f status.awk log_output</pre>
|
||
</div>
|
||
<div class="sect2" lang="en" xml:lang="en">
|
||
<div class="titlepage">
|
||
<div>
|
||
<div>
|
||
<h3 class="title"><a id="idm1341784"></a>Extracting Transaction Histories</h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<p>
|
||
Another useful debugging aid is to print out the complete history
|
||
of a transaction. The awk script txn.awk allows you to do that.
|
||
The following command line, where log_output is the output of the
|
||
<a href="../api_reference/C/db_printlog.html" class="olink">db_printlog</a> utility and txnlist is a comma-separated list of transaction
|
||
IDs, will display all log records associated with the designated
|
||
transaction ids:
|
||
</p>
|
||
<pre class="programlisting">awk -f txn.awk TXN=txnlist log_output</pre>
|
||
</div>
|
||
<div class="sect2" lang="en" xml:lang="en">
|
||
<div class="titlepage">
|
||
<div>
|
||
<div>
|
||
<h3 class="title"><a id="idm986800"></a>Extracting File Histories</h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<p>
|
||
The awk script fileid.awk allows you to extract all log records
|
||
that refer to a designated file. The syntax for the fileid.awk
|
||
script is the following, where log_output is the output of
|
||
db_printlog and fids is a comma-separated list of fileids:
|
||
</p>
|
||
<pre class="programlisting">awk -f fileid.awk PGNO=fids log_output</pre>
|
||
</div>
|
||
<div class="sect2" lang="en" xml:lang="en">
|
||
<div class="titlepage">
|
||
<div>
|
||
<div>
|
||
<h3 class="title"><a id="idm1437640"></a>Extracting Page Histories</h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<p>
|
||
The awk script pgno.awk allows you to extract all log records that
|
||
refer to designated page numbers. However, because this script
|
||
will extract records with the designated page numbers for all
|
||
files, it is most useful in conjunction with the fileid script.
|
||
The syntax for the pgno.awk script is the following, where
|
||
log_output is the output of db_printlog and pgnolist is a
|
||
comma-separated list of page numbers:
|
||
</p>
|
||
<pre class="programlisting">awk -f pgno.awk PGNO=pgnolist log_output</pre>
|
||
</div>
|
||
<div class="sect2" lang="en" xml:lang="en">
|
||
<div class="titlepage">
|
||
<div>
|
||
<div>
|
||
<h3 class="title"><a id="idm680600"></a>Other log processing tools</h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<p>
|
||
The awk script count.awk prints out the number of log records
|
||
encountered that belonged to some transaction (that is, the number
|
||
of log records excluding those for checkpoints and
|
||
non-transaction-protected operations).
|
||
</p>
|
||
<p>
|
||
The script range.awk will extract a subset of a log. This is
|
||
useful when the output of <a href="../api_reference/C/db_printlog.html" class="olink">db_printlog</a> utility is too large to be
|
||
reasonably manipulated with an editor or other tool. The syntax
|
||
for range.awk is the following, where
|
||
<span class="bold"><strong>sf</strong></span> and
|
||
<span class="bold"><strong>so</strong></span> represent the LSN of the
|
||
beginning of the sublog you want to extract, and
|
||
<span class="bold"><strong>ef</strong></span> and
|
||
<span class="bold"><strong>eo</strong></span> represent the LSN of the end of
|
||
the sublog you want to extract:
|
||
</p>
|
||
<pre class="programlisting"> awk -f range.awk START_FILE=sf START_OFFSET=so END_FILE=ef \
|
||
END_OFFSET=eo log_output </pre>
|
||
</div>
|
||
</div>
|
||
<div class="navfooter">
|
||
<hr />
|
||
<table width="100%" summary="Navigation footer">
|
||
<tr>
|
||
<td width="40%" align="left"><a accesskey="p" href="debug_runtime.html">Prev</a> </td>
|
||
<td width="20%" align="center">
|
||
<a accesskey="u" href="debug.html">Up</a>
|
||
</td>
|
||
<td width="40%" align="right"> <a accesskey="n" href="build_android_intro.html">Next</a></td>
|
||
</tr>
|
||
<tr>
|
||
<td width="40%" align="left" valign="top">Run-time error information </td>
|
||
<td width="20%" align="center">
|
||
<a accesskey="h" href="index.html">Home</a>
|
||
</td>
|
||
<td width="40%" align="right" valign="top"> Chapter 4. Building Berkeley DB for Android</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</body>
|
||
</html>
|