Berkeley DB Reference Guide:
Logging Subsystem

PrevRefNext

Berkeley DB and logging

The Logging subsystem is the logging facility used by Berkeley DB. It is largely Berkeley DB-specific, although it is potentially useful outside of the Berkeley DB package for applications wanting write-ahead logging support. Applications wanting to use the log for purposes other than logging file modifications based on a set of open file descriptors will almost certainly need to make source code modifications to the Berkeley DB code base.

A log can be shared by any number of threads of control. The DB_ENV->open interface is used to open a log. When the log is no longer in use, it should be closed using the DB_ENV->close interface.

Individual log entries are identified by log sequence numbers. Log sequence numbers are stored in an opaque object, a DB_LSN.

The DB_ENV->log_put function is used to append new log records to the log. Optionally, the DB_CHECKPOINT flag can be used to output a checkpoint log record (indicating that the log is consistent to that point, and recoverable after a system or application failure), as well as open-file information.

The DB_ENV->log_cursor function is used to allocate a log cursor. Log cursors have two methods: DB_LOGC->get function to retrieve log records from the log, and DB_LOGC->close function to destroy the cursor.

There are additional interfaces for integrating the log subsystem with a transaction processing system:

DB_ENV->log_register and DB_ENV->log_unregister
These interfaces associate files with identification numbers. These identification numbers are logged so that transactional recovery correctly associates log records with the appropriate files.

DB_ENV->log_flush
Flushes the log up to a particular log sequence number.

log_compare
Allows applications to compare any two log sequence numbers.

DB_ENV->log_file
Maps a log sequence number to the specific log file that contains it.

DB_ENV->log_archive
Returns various sets of log filenames. These interfaces are used for database administration; for example, to determine if log files may safely be removed from the system.

DB_ENV->log_stat
The display db_stat utility uses the DB_ENV->log_stat interface to display statistics about the log.

DB_ENV->remove
The log meta-information (but not the log files themselves) may be removed using the DB_ENV->remove interface.

PrevRefNext

Copyright Sleepycat Software