~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/docs/ref/debug/printlog.html

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--$Id: printlog.so,v 10.28 2001/05/26 16:28:37 bostic Exp $-->
 
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
 
3
<!--All rights reserved.-->
 
4
<html>
 
5
<head>
 
6
<title>Berkeley DB Reference Guide: Reviewing Berkeley DB log files</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++">
 
9
</head>
 
10
<body bgcolor=white>
 
11
<table width="100%"><tr valign=top>
 
12
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Debugging Applications</dl></h3></td>
 
13
<td align=right><a href="../../ref/debug/runtime.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/debug/common.html"><img src="../../images/next.gif" alt="Next"></a>
 
14
</td></tr></table>
 
15
<p>
 
16
<h1 align=center>Reviewing Berkeley DB log files</h1>
 
17
<p>If you are running with transactions and logging, the <a href="../../utility/db_printlog.html">db_printlog</a>
 
18
utility can be a useful debugging aid.  The <a href="../../utility/db_printlog.html">db_printlog</a> utility
 
19
will display the contents of your log files in a human readable (and
 
20
machine-processable) format.
 
21
<p>The <a href="../../utility/db_printlog.html">db_printlog</a> utility will attempt to display any and all
 
22
log files present in a designated db_home directory.  For each log record,
 
23
<a href="../../utility/db_printlog.html">db_printlog</a> will display a line of the form:
 
24
<p><blockquote><pre>[22][28]db_big: rec: 43 txnid 80000963 prevlsn [21][10483281]</pre></blockquote>
 
25
<p>The opening numbers in square brackets are the <i>log sequence
 
26
number</i> (<i>LSN</i>) of the log record being displayed.  The first
 
27
number indicates the log file in which the record appears, and the
 
28
second number indicates the offset in that file of the record.
 
29
<p>The first character string identifies the particular log operation being
 
30
reported.  The log records corresponding to particular operations are
 
31
described following.  The rest of the line consists of name/value pairs.
 
32
<p>The rec field indicates the record type (this is used to dispatch records
 
33
in the log to appropriate recovery functions).
 
34
<p>The txnid field identifies the transaction for which this record was
 
35
written.  A txnid of 0 means that the record was written outside the
 
36
context of any transaction.  You will see these most frequently for
 
37
checkpoints.
 
38
<p>Finally, the prevlsn contains the LSN of the last record for this
 
39
transaction.  By following prevlsn fields, you can accumulate all the
 
40
updates for a particular transaction.  During normal abort processing,
 
41
this field is used to quickly access all the records for a particular
 
42
transaction.
 
43
<p>After the initial line identifying the record type, each field of the log
 
44
record is displayed, one item per line.  There are several fields that
 
45
appear in many different records and a few fields that appear only in
 
46
some records.
 
47
<p>The following table presents each currently written log record type with
 
48
a brief description of the operation it describes.
 
49
<!--START LOG RECORD TYPES-->
 
50
<p><table border=1>
 
51
<tr><th>Log Record Type</th><th>Description</th></tr>
 
52
<tr><td>bam_adj</td><td>Used when we insert/remove an index into/from the page header of a Btree page.</td></tr>
 
53
<tr><td>bam_cadjust</td><td>Keeps track of record counts in a Btree or Recno database.</td></tr>
 
54
<tr><td>bam_cdel</td><td>Used to mark a record on a page as deleted.</td></tr>
 
55
<tr><td>bam_curadj</td><td>Used to adjust a cursor location when a nearby record changes in a Btree database.</td></tr>
 
56
<tr><td>bam_pg_alloc</td><td>Indicates that we allocated a page to a Btree.</td></tr>
 
57
<tr><td>bam_pg_free</td><td>Indicates that we freed a page in the Btree (freed pages are added to a freelist and reused).</td></tr>
 
58
<tr><td>bam_rcuradj</td><td>Used to adjust a cursor location when a nearby record changes in a Recno database.</td></tr>
 
59
<tr><td>bam_repl</td><td>Describes a replace operation on a record.</td></tr>
 
60
<tr><td>bam_root</td><td>Describes an assignment of a root page.</td></tr>
 
61
<tr><td>bam_rsplit</td><td>Describes a reverse page split.</td></tr>
 
62
<tr><td>bam_split</td><td>Describes a page split.</td></tr>
 
63
<tr><td>crdel_delete</td><td>Describes the removal of a Berkeley DB file.</td></tr>
 
64
<tr><td>crdel_fileopen</td><td>Describes a Berkeley DB file create attempt.</td></tr>
 
65
<tr><td>crdel_metapage</td><td>Describes the creation of a metadata page for a new file.</td></tr>
 
66
<tr><td>crdel_metasub</td><td>Describes the creation of a metadata page for a subdatabase.</td></tr>
 
67
<tr><td>crdel_rename</td><td>Describes a file rename operation.</td></tr>
 
68
<tr><td>db_addrem</td><td>Add or remove an item from a page of duplicates.</td></tr>
 
69
<tr><td>db_big</td><td>Add an item to an overflow page (<i>overflow pages</i> contain items too large to place on the main page)</td></tr>
 
70
<tr><td>db_debug</td><td>Log debugging message.</td></tr>
 
71
<tr><td>db_noop</td><td>This marks an operation that did nothing but update the LSN on a page.</td></tr>
 
72
<tr><td>db_ovref</td><td>Increment or decrement the reference count for a big item.</td></tr>
 
73
<tr><td>db_relink</td><td>Fix prev/next chains on duplicate pages because a page was added or removed.</td></tr>
 
74
<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>
 
75
<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>
 
76
<tr><td>ham_curadj</td><td>Used to adjust a cursor location when a nearby record changes in a Hash database.</td></tr>
 
77
<tr><td>ham_groupalloc</td><td>Allocate some number of contiguous pages to the Hash database.</td></tr>
 
78
<tr><td>ham_insdel</td><td>Insert/delete an item on a Hash page.</td></tr>
 
79
<tr><td>ham_metagroup</td><td>Update the metadata page to reflect the allocation of a sequence of contiguous pages.</td></tr>
 
80
<tr><td>ham_newpage</td><td>Adds or removes overflow pages from a Hash bucket.</td></tr>
 
81
<tr><td>ham_replace</td><td>Handle updates to records that are on the main page.</td></tr>
 
82
<tr><td>ham_splitdata</td><td>Record the page data for a split.</td></tr>
 
83
<tr><td>log_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>
 
84
<tr><td>qam_add</td><td>Describes the actual addition of a new record to a Queue.</td></tr>
 
85
<tr><td>qam_del</td><td>Delete a record in a Queue.</td></tr>
 
86
<tr><td>qam_delext</td><td>Delete a record in a Queue with extents.</td></tr>
 
87
<tr><td>qam_delete</td><td>Remove a Queue extent file.</td></tr>
 
88
<tr><td>qam_incfirst</td><td>Increments the record number that refers to the first record in the database.</td></tr>
 
89
<tr><td>qam_mvptr</td><td>Indicates that we changed the reference to either or both of the first and current records in the file.</td></tr>
 
90
<tr><td>qam_rename</td><td>Rename a Queue extent file.</td></tr>
 
91
<tr><td>txn_child</td><td>Commit a child transaction.</td></tr>
 
92
<tr><td>txn_ckp</td><td>Transaction checkpoint.</td></tr>
 
93
<tr><td>txn_regop</td><td>Logs a regular (non-child) transaction commit.</td></tr>
 
94
<tr><td>txn_xa_regop</td><td>Logs a prepare message.</td></tr>
 
95
</table>
 
96
<!--END LOG RECORD TYPES-->
 
97
<h3>Augmenting the Log for Debugging</h3>
 
98
<p>When debugging applications, it is sometimes useful to log not only the
 
99
actual operations that modify pages, but also the underlying Berkeley DB
 
100
functions being executed.  This form of logging can add significant bulk
 
101
to your log, but can permit debugging application errors that are almost
 
102
impossible to find any other way.  To turn on these log messages, specify
 
103
the --enable-debug_rop and --enable-debug_wop configuration options when
 
104
configuring Berkeley DB.  See <a href="../../ref/build_unix/conf.html">Configuring
 
105
Berkeley DB</a> for more information.
 
106
<h3>Extracting Committed Transactions and Transaction Status</h3>
 
107
<p>Sometimes, it is helpful to use the human-readable log output to
 
108
determine which transactions committed and aborted.  The awk script,
 
109
commit.awk, (found in the db_printlog directory of the Berkeley DB
 
110
distribution) allows you to do just that.  The following command,
 
111
where log_output is the output of db_printlog, will display a list of
 
112
the transaction IDs of all committed transactions found in the log:
 
113
<p><blockquote><pre>awk -f commit.awk log_output</pre></blockquote>
 
114
<p>If you need a complete list of both committed and aborted transactions,
 
115
then the script status.awk will produce it.  The syntax is as follows:
 
116
<p><blockquote><pre>awk -f status.awk log_output</pre></blockquote>
 
117
<h3>Extracting Transaction Histories</h3>
 
118
<p>Another useful debugging aid is to print out the complete history of a
 
119
transaction.  The awk script txn.awk allows you to do that.  The
 
120
following command line, where log_output is the output of
 
121
<a href="../../utility/db_printlog.html">db_printlog</a> and txnlist is a comma-separated list of transaction
 
122
IDs, will display all log records associated with the designated
 
123
transaction ids:
 
124
<p><blockquote><pre>awk -f txn.awk TXN=txnlist log_output</pre></blockquote>
 
125
<h3>Extracting File Histories</h3>
 
126
<p>The awk script fileid.awk allows you to extract all log records that
 
127
refer to a designated file.  The syntax for the fileid.awk script is
 
128
the following, where log_output is the output of db_printlog and fids
 
129
is a comma-separated list of fileids:
 
130
<p><blockquote><pre>awk -f fileid.awk PGNO=fids log_output</pre></blockquote>
 
131
<h3>Extracting Page Histories</h3>
 
132
<p>The awk script pgno.awk allows you to extract all log records that refer
 
133
to designated page numbers.  However, because this script will extract
 
134
records with the designated page numbers for all files, it is most
 
135
useful in conjunction with the fileid script.  The syntax for the
 
136
pgno.awk script is the following, where log_output is the output of
 
137
db_printlog and pgnolist is a comma-separated list of page numbers:
 
138
<p><blockquote><pre>awk -f pgno.awk PGNO=pgnolist log_output</pre></blockquote>
 
139
<h3>Other log processing tools</h3>
 
140
<p>The awk script count.awk prints out the number of log records
 
141
encountered that belonged to some transaction (that is, the number of
 
142
log records excluding those for checkpoints and
 
143
non-transaction-protected operations).
 
144
<p>The script range.awk will extract a subset of a log.  This is useful
 
145
when the output of <a href="../../utility/db_printlog.html">db_printlog</a> is too large to be reasonably
 
146
manipulated with an editor or other tool.  The syntax for range.awk is
 
147
the following, where <b>sf</b> and <b>so</b> represent the LSN
 
148
of the beginning of the sublog you want to extract, and <b>ef</b> and
 
149
<b>eo</b> represent the LSN of the end of the sublog you want to
 
150
extract:
 
151
<p><blockquote><pre>awk -f range.awk START_FILE=sf START_OFFSET=so END_FILE=ef END_OFFSET=eo log_output</pre></blockquote>
 
152
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/debug/runtime.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/debug/common.html"><img src="../../images/next.gif" alt="Next"></a>
 
153
</td></tr></table>
 
154
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
 
155
</body>
 
156
</html>