Berkeley DB Reference Guide: Logging Subsystem
Полезная информация

Berkeley DB Reference Guide: Logging Subsystem

Berkeley DB and logging

The logging subsystem is the somewhat general-purpose logging facility used by Berkeley DB. This module is potentially useful outside of the Berkeley DB package for processes that require write-ahead logging support, but is less likely to be generally useful than the memory pool or locking subsystems.

A log can be shared by any number of processes and threads within processes. The log_open interface opens, and optionally creates, a log. When the log is no longer in use, it should be closed, using the log_close interface. Specific log entries are identified by log sequence numbers. Log sequence numbers are held in an opaque object, a DB_LSN.

The log_put interface is used to append new log records to the log. Optionally, the DB_CHECKPOINT flag can be used to cause any log record to include checkpoint information, such that the log is consistent to that point and recoverable after a system or application failure. The log_get interface is used to retrieve log records from the log.

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

The log_register and log_unregister interfaces associate files with identification numbers. These identification numbers are logged so that log recovery correctly associates database changes with the appropriate files.

The log_flush interface flushes the log up to a particular log sequence number.

The log_compare interface allows applications to compare any two log sequence numbers.

The log_file interface maps a log sequence number to the specific log file which contains it. The log_archive interface returns various sets of log file names. These interfaces are used for database administration, e.g., to determine if log files may be removed from the system.

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

Finally, the log (but not the log files themselves) may be discarded using the log_unlink interface.