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