• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/programmer_reference/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Reviewing Berkeley DB log files</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
10    <link rel="up" href="debug.html" title="Chapter��24.�� Debugging Applications" />
11    <link rel="prev" href="debug_runtime.html" title="Run-time error information" />
12    <link rel="next" href="build_brew.html" title="Chapter��25.�� Building Berkeley DB for the BREW simulator" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Reviewing Berkeley DB log files</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="debug_runtime.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��24.��
23		Debugging Applications
24        </th>
25          <td width="20%" align="right">��<a accesskey="n" href="build_brew.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="sect1" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title" style="clear: both"><a id="debug_printlog"></a>Reviewing Berkeley DB log files</h2>
35          </div>
36        </div>
37      </div>
38      <div class="toc">
39        <dl>
40          <dt>
41            <span class="sect2">
42              <a href="debug_printlog.html#id1628132">Augmenting the Log for Debugging</a>
43            </span>
44          </dt>
45          <dt>
46            <span class="sect2">
47              <a href="debug_printlog.html#id1627874">Extracting Committed Transactions and Transaction Status</a>
48            </span>
49          </dt>
50          <dt>
51            <span class="sect2">
52              <a href="debug_printlog.html#id1627850">Extracting Transaction Histories</a>
53            </span>
54          </dt>
55          <dt>
56            <span class="sect2">
57              <a href="debug_printlog.html#id1627760">Extracting File Histories</a>
58            </span>
59          </dt>
60          <dt>
61            <span class="sect2">
62              <a href="debug_printlog.html#id1627731">Extracting Page Histories</a>
63            </span>
64          </dt>
65          <dt>
66            <span class="sect2">
67              <a href="debug_printlog.html#id1627742">Other log processing tools</a>
68            </span>
69          </dt>
70        </dl>
71      </div>
72      <p>If you are running with transactions and logging, the <a href="../api_reference/C/db_printlog.html" class="olink">db_printlog utility</a> can be a useful debugging aid.  The <a href="../api_reference/C/db_printlog.html" class="olink">db_printlog utility</a> will display the contents of your log files in a human readable (and machine-readable) format.</p>
73      <p>The <a href="../api_reference/C/db_printlog.html" class="olink">db_printlog utility</a> 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 utility</a> will display a line of the form:</p>
74      <pre class="programlisting">[22][28]db_big: rec: 43 txnid 80000963 prevlsn [21][10483281]</pre>
75      <p>The opening numbers in square brackets are the <span class="emphasis"><em>log sequence
76number</em></span> (<span class="emphasis"><em>LSN</em></span>) of the log record being displayed.  The first
77number indicates the log file in which the record appears, and the
78second number indicates the offset in that file of the record.</p>
79      <p>The first character string identifies the particular log operation being
80reported.  The log records corresponding to particular operations are
81described following.  The rest of the line consists of name/value pairs.</p>
82      <p>The rec field indicates the record type (this is used to dispatch records
83in the log to appropriate recovery functions).</p>
84      <p>The txnid field identifies the transaction for which this record was
85written.  A txnid of 0 means that the record was written outside the
86context of any transaction.  You will see these most frequently for
87checkpoints.</p>
88      <p>Finally, the prevlsn contains the LSN of the last record for this
89transaction.  By following prevlsn fields, you can accumulate all the
90updates for a particular transaction.  During normal abort processing,
91this field is used to quickly access all the records for a particular
92transaction.</p>
93      <p>After the initial line identifying the record type, each field of the log
94record is displayed, one item per line.  There are several fields that
95appear in many different records and a few fields that appear only in
96some records.</p>
97      <p>The following table presents each currently written log record type with
98a brief description of the operation it describes.  Any of these
99record types may have the string "_debug" appended if they
100were 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
101system was configured with <a class="link" href="build_unix_conf.html#build_unix_conf.--enable-diagnostic">--enable-diagnostic</a>.</p>
102      <div class="informaltable">
103        <table border="1" width="80%">
104          <colgroup>
105            <col />
106            <col />
107          </colgroup>
108          <thead>
109            <tr>
110              <th>Log Record Type</th>
111              <th>Description</th>
112            </tr>
113          </thead>
114          <tbody>
115            <tr>
116              <td>bam_adj</td>
117              <td>Used when we insert/remove an index into/from the page header of a Btree page.</td>
118            </tr>
119            <tr>
120              <td>bam_cadjust</td>
121              <td>Keeps track of record counts in a Btree or Recno database.</td>
122            </tr>
123            <tr>
124              <td>bam_cdel</td>
125              <td>Used to mark a record on a page as deleted.</td>
126            </tr>
127            <tr>
128              <td>bam_curadj</td>
129              <td>Used to adjust a cursor location when a nearby record changes in a Btree database.</td>
130            </tr>
131            <tr>
132              <td>bam_merge</td>
133              <td>Used to merge two Btree database pages during compaction.</td>
134            </tr>
135            <tr>
136              <td>bam_pgno</td>
137              <td>Used to replace a page number in a Btree record.</td>
138            </tr>
139            <tr>
140              <td>bam_rcuradj</td>
141              <td>Used to adjust a cursor location when a nearby record changes in a Recno database.</td>
142            </tr>
143            <tr>
144              <td>bam_relink</td>
145              <td>Fix leaf page prev/next chain when a page is removed.</td>
146            </tr>
147            <tr>
148              <td>bam_repl</td>
149              <td>Describes a replace operation on a record.</td>
150            </tr>
151            <tr>
152              <td>bam_root</td>
153              <td>Describes an assignment of a root page.</td>
154            </tr>
155            <tr>
156              <td>bam_rsplit</td>
157              <td>Describes a reverse page split.</td>
158            </tr>
159            <tr>
160              <td>bam_split</td>
161              <td>Describes a page split.</td>
162            </tr>
163            <tr>
164              <td>crdel_inmem_create</td>
165              <td>Record the creation of an in-memory named database.</td>
166            </tr>
167            <tr>
168              <td>crdel_inmem_remove</td>
169              <td>Record the removal of an in-memory named database.</td>
170            </tr>
171            <tr>
172              <td>crdel_inmem_rename</td>
173              <td>Record the rename of an in-memory named database.</td>
174            </tr>
175            <tr>
176              <td>crdel_metasub</td>
177              <td>Describes the creation of a metadata page for a subdatabase.</td>
178            </tr>
179            <tr>
180              <td>db_addrem</td>
181              <td>Add or remove an item from a page of duplicates.</td>
182            </tr>
183            <tr>
184              <td>db_big</td>
185              <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>
186            </tr>
187            <tr>
188              <td>db_cksum</td>
189              <td>Unable to checksum a page.</td>
190            </tr>
191            <tr>
192              <td>db_debug</td>
193              <td>Log debugging message.</td>
194            </tr>
195            <tr>
196              <td>db_noop</td>
197              <td>This marks an operation that did nothing but update the LSN on a page.</td>
198            </tr>
199            <tr>
200              <td>db_ovref</td>
201              <td>Increment or decrement the reference count for a big item.</td>
202            </tr>
203            <tr>
204              <td>db_pg_alloc</td>
205              <td>Indicates we allocated a page to a database.</td>
206            </tr>
207            <tr>
208              <td>db_pg_free</td>
209              <td>Indicates we freed a page (freed pages are added to a freelist and reused).</td>
210            </tr>
211            <tr>
212              <td>db_pg_freedata</td>
213              <td>Indicates we freed a page that still contained data entries (freed pages are added to a freelist and reused.)</td>
214            </tr>
215            <tr>
216              <td>db_pg_init</td>
217              <td>Indicates we reinitialized a page during a truncate.</td>
218            </tr>
219            <tr>
220              <td>db_pg_sort</td>
221              <td>Sort the free page list and free pages at the end of the file.</td>
222            </tr>
223            <tr>
224              <td>dbreg_register</td>
225              <td>Records an open of a file (mapping the filename to a log-id that is used in subsequent log operations).</td>
226            </tr>
227            <tr>
228              <td>fop_create</td>
229              <td>Create a file in the file system.</td>
230            </tr>
231            <tr>
232              <td>fop_file_remove</td>
233              <td>Remove a name in the file system.</td>
234            </tr>
235            <tr>
236              <td>fop_remove</td>
237              <td>Remove a file in the file system.</td>
238            </tr>
239            <tr>
240              <td>fop_rename</td>
241              <td>Rename a file in the file system.</td>
242            </tr>
243            <tr>
244              <td>fop_write</td>
245              <td>Write bytes to an object in the file system.</td>
246            </tr>
247            <tr>
248              <td>ham_chgpg</td>
249              <td>Used to adjust a cursor location when a Hash page is removed, and its elements are moved to a different Hash page.</td>
250            </tr>
251            <tr>
252              <td>ham_copypage</td>
253              <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>
254            </tr>
255            <tr>
256              <td>ham_curadj</td>
257              <td>Used to adjust a cursor location when a nearby record changes in a Hash database.</td>
258            </tr>
259            <tr>
260              <td>ham_groupalloc</td>
261              <td>Allocate some number of contiguous pages to the Hash database.</td>
262            </tr>
263            <tr>
264              <td>ham_insdel</td>
265              <td>Insert/delete an item on a Hash page.</td>
266            </tr>
267            <tr>
268              <td>ham_metagroup</td>
269              <td>Update the metadata page to reflect the allocation of a sequence of contiguous pages.</td>
270            </tr>
271            <tr>
272              <td>ham_newpage</td>
273              <td>Adds or removes overflow pages from a Hash bucket.</td>
274            </tr>
275            <tr>
276              <td>ham_replace</td>
277              <td>Handle updates to records that are on the main page.</td>
278            </tr>
279            <tr>
280              <td>ham_splitdata</td>
281              <td>Record the page data for a split.</td>
282            </tr>
283            <tr>
284              <td>qam_add</td>
285              <td>Describes the actual addition of a new record to a Queue.</td>
286            </tr>
287            <tr>
288              <td>qam_del</td>
289              <td>Delete a record in a Queue.</td>
290            </tr>
291            <tr>
292              <td>qam_delext</td>
293              <td>Delete a record in a Queue with extents.</td>
294            </tr>
295            <tr>
296              <td>qam_incfirst</td>
297              <td>Increments the record number that refers to the first record in the database.</td>
298            </tr>
299            <tr>
300              <td>qam_mvptr</td>
301              <td>Indicates we changed the reference to either or both of the first and current records in the file.</td>
302            </tr>
303            <tr>
304              <td>txn_child</td>
305              <td>Commit a child transaction.</td>
306            </tr>
307            <tr>
308              <td>txn_ckp</td>
309              <td>Transaction checkpoint.</td>
310            </tr>
311            <tr>
312              <td>txn_recycle</td>
313              <td>Transaction IDs wrapped.</td>
314            </tr>
315            <tr>
316              <td>txn_regop</td>
317              <td>Logs a regular (non-child) transaction commit.</td>
318            </tr>
319            <tr>
320              <td>txn_xa_regop</td>
321              <td>Logs a prepare message.</td>
322            </tr>
323          </tbody>
324        </table>
325      </div>
326      <div class="sect2" lang="en" xml:lang="en">
327        <div class="titlepage">
328          <div>
329            <div>
330              <h3 class="title"><a id="id1628132"></a>Augmenting the Log for Debugging</h3>
331            </div>
332          </div>
333        </div>
334        <p>When debugging applications, it is sometimes useful to log not only the
335actual operations that modify pages, but also the underlying Berkeley DB
336functions being executed.  This form of logging can add significant bulk
337to your log, but can permit debugging application errors that are almost
338impossible to find any other way.  To turn on these log messages, specify
339the --enable-debug_rop and --enable-debug_wop configuration options when
340configuring Berkeley DB.  See <a class="xref" href="build_unix_conf.html" title="Configuring Berkeley DB">Configuring Berkeley DB</a> for more information.</p>
341      </div>
342      <div class="sect2" lang="en" xml:lang="en">
343        <div class="titlepage">
344          <div>
345            <div>
346              <h3 class="title"><a id="id1627874"></a>Extracting Committed Transactions and Transaction Status</h3>
347            </div>
348          </div>
349        </div>
350        <p>Sometimes, it is helpful to use the human-readable log output to
351determine which transactions committed and aborted.  The awk script,
352commit.awk, (found in the db_printlog directory of the Berkeley DB
353distribution) allows you to do just that.  The following command,
354where log_output is the output of db_printlog, will display a list of
355the transaction IDs of all committed transactions found in the log:</p>
356        <pre class="programlisting">awk -f commit.awk log_output</pre>
357        <p>If you need a complete list of both committed and aborted transactions,
358then the script status.awk will produce it.  The syntax is as follows:</p>
359        <pre class="programlisting">awk -f status.awk log_output</pre>
360      </div>
361      <div class="sect2" lang="en" xml:lang="en">
362        <div class="titlepage">
363          <div>
364            <div>
365              <h3 class="title"><a id="id1627850"></a>Extracting Transaction Histories</h3>
366            </div>
367          </div>
368        </div>
369        <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 utility</a> and txnlist is a comma-separated list of transaction IDs, will display all log records associated with the designated transaction ids:</p>
370        <pre class="programlisting">awk -f txn.awk TXN=txnlist log_output</pre>
371      </div>
372      <div class="sect2" lang="en" xml:lang="en">
373        <div class="titlepage">
374          <div>
375            <div>
376              <h3 class="title"><a id="id1627760"></a>Extracting File Histories</h3>
377            </div>
378          </div>
379        </div>
380        <p>The awk script fileid.awk allows you to extract all log records that
381refer to a designated file.  The syntax for the fileid.awk script is
382the following, where log_output is the output of db_printlog and fids
383is a comma-separated list of fileids:</p>
384        <pre class="programlisting">awk -f fileid.awk PGNO=fids log_output</pre>
385      </div>
386      <div class="sect2" lang="en" xml:lang="en">
387        <div class="titlepage">
388          <div>
389            <div>
390              <h3 class="title"><a id="id1627731"></a>Extracting Page Histories</h3>
391            </div>
392          </div>
393        </div>
394        <p>The awk script pgno.awk allows you to extract all log records that refer
395to designated page numbers.  However, because this script will extract
396records with the designated page numbers for all files, it is most
397useful in conjunction with the fileid script.  The syntax for the
398pgno.awk script is the following, where log_output is the output of
399db_printlog and pgnolist is a comma-separated list of page numbers:</p>
400        <pre class="programlisting">awk -f pgno.awk PGNO=pgnolist log_output</pre>
401      </div>
402      <div class="sect2" lang="en" xml:lang="en">
403        <div class="titlepage">
404          <div>
405            <div>
406              <h3 class="title"><a id="id1627742"></a>Other log processing tools</h3>
407            </div>
408          </div>
409        </div>
410        <p>The awk script count.awk prints out the number of log records
411encountered that belonged to some transaction (that is, the number of
412log records excluding those for checkpoints and
413non-transaction-protected operations).</p>
414        <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 utility</a> 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>
415        <pre class="programlisting">awk -f range.awk START_FILE=sf START_OFFSET=so END_FILE=ef END_OFFSET=eo log_output</pre>
416      </div>
417    </div>
418    <div class="navfooter">
419      <hr />
420      <table width="100%" summary="Navigation footer">
421        <tr>
422          <td width="40%" align="left"><a accesskey="p" href="debug_runtime.html">Prev</a>��</td>
423          <td width="20%" align="center">
424            <a accesskey="u" href="debug.html">Up</a>
425          </td>
426          <td width="40%" align="right">��<a accesskey="n" href="build_brew.html">Next</a></td>
427        </tr>
428        <tr>
429          <td width="40%" align="left" valign="top">Run-time error information��</td>
430          <td width="20%" align="center">
431            <a accesskey="h" href="index.html">Home</a>
432          </td>
433          <td width="40%" align="right" valign="top">��Chapter��25.��
434		Building Berkeley DB for the BREW simulator
435        </td>
436        </tr>
437      </table>
438    </div>
439  </body>
440</html>
441