Transaction log

Transaction log

In the field of databases in computer science, a transaction log (also database log or binary log) is a history of actions executed by a database management system to guarantee ACID properties over crashes or hardware failures. Physically, a log is a file of updates done to the database, stored in stable storage.

If, after a start, the database is found in an inconsistent state or not been shut down properly, the database management system reviews the database logs for uncommitted transactions and rolls back the changes made by these transactions. Additionally, all transactions that are already committed but whose changes were not yet materialized in the database are re-applied. Both are done to ensure atomicity and durability of transactions.

This term is not to be confused with other, human-readable logs that a database management system usually provides.

Anatomy of a general database log

A database log record is made up of

  • Log Sequence Number: A unique id for a log record. With LSNs, logs can be recovered in constant time. Most logs' LSNs are assigned in monotonically increasing order, which is useful in recovery algorithms, like ARIES.
  • Prev LSN: A link to the last log record. This implies database logs are constructed in linked list form.
  • Transaction ID number: A reference to the database transaction generating the log record.
  • Type: Describes the type of database log record.
  • information about the actual changes that triggered the log record to be written

Types of database log records

All log records include the general log attributes above, and also other attributes depending on their type (which is recorded in the Type attribute, as above).

  • Update Log Record notes an update (change) to the database. It includes this extra information:
    • PageID: A reference to the Page ID of the modified page.
    • Length and Offset: Length in bytes and offset of the page are usually included.
    • Before and After Images: Includes the value of the bytes of page before and after the page change. Some databases may have logs which include one or both images.
  • Compensation Log Record notes the rollback of a particular change to the database. Each correspond with exactly one other Update Log Record (although the corresponding update log record is not typically stored in the Compensation Log Record). It includes this extra information:
    • undoNextLSN: This field contains the LSN of the next log record that is to be undone for transaction that wrote the last Update Log.
  • Commit Record notes a decision to commit a transaction.
  • Abort Record notes a decision to abort and hence rollback a transaction.
  • Checkpoint Record notes that a checkpoint has been made. These are used to speed up recovery. They record information that eliminates the need to read a long way into the log's past. This varies according to checkpoint algorithm. If all dirty pages are flushed while creating the checkpoint (as in PostgreSQL), it might contain:
    • redoLSN: This is a reference to the first log record that corresponds to a dirty page. i.e. the first update that wasn't flushed at checkpoint time. This is where redo must begin on recovery.
    • undoLSN: This is a reference to the oldest log record of the oldest in-progress transaction. This is the oldest log record needed to undo all in-progress transactions.
  • Completion Record notes that all work has been done for this particular transaction. (It has been fully committed or aborted)

Tables

These tables are maintained in memory, and can be efficiently reconstructed (if not exactly, to an equivalent state) from the log and the database:

  • Transaction Table: The table contains one entry for each active transaction. This includes Transaction ID and lastLSN, where lastLSN describes the LSN of the most recent log record for the transaction.
  • Dirty Page Table: The table contains one entry for each dirty page that hasn't been written to disk. The entry contains recLSN, where recLSN is the LSN of the first log record that caused the page to be dirty.

Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Transaction processing system — A Transaction Processing System To be considered a transaction processing system the computer must pass the ACID test.From a technical perspective, a Transaction Processing System (or Transaction Processing Monitor) monitors transaction programs …   Wikipedia

  • Transaction processing — For other uses, see Transaction (disambiguation). In computer science, transaction processing is information processing that is divided into individual, indivisible operations, called transactions. Each transaction must succeed or fail as a… …   Wikipedia

  • Transaction authentication number — A Transaction authentication number or TAN is used by some online banking services as a form of single use passwords to authorize financial transactions. TANs are a second layer of security above and beyond the traditional single password… …   Wikipedia

  • Database transaction — A transaction comprises a unit of work performed within a database management system (or similar system) against a database, and treated in a coherent and reliable way independent of other transactions. Transactions in a database environment have …   Wikipedia

  • Online transaction processing — Online transaction processing, or OLTP, refers to a class of systems that facilitate and manage transaction oriented applications, typically for data entry and retrieval transaction processing. The term is somewhat ambiguous; some understand a… …   Wikipedia

  • Common Log File System — (CLFS) is a general purpose logging subsystem that is accessible to both kernel mode as well as user mode applications for building high performance transaction logs. It was introduced with Windows Server 2003 R2 and included in later Windows OSs …   Wikipedia

  • Kernel Transaction Manager — (KTM) is a component of the Windows operating system kernel in Windows Vista and Windows Server 2008 that enables applications to use atomic transactions on resources by making them available as kernel objects. The transaction engine, which… …   Wikipedia

  • Microsoft Transaction Server — (MTS) was software that provided services to Component Object Model (COM) software components, to make it easier to create large distributed applications. The major services provided by MTS were automated transaction management, instance… …   Wikipedia

  • Redo log — In the Oracle RDBMS environment, redo logs comprise files in a proprietary format which log a history of all changes made to the database. Each redo log file consists of redo records. A redo record, also called a redo entry, holds a group of… …   Wikipedia

  • Intent log — An intent log is a mechanism used to make computer operations more resilient in the event of failures. They are used in database software, transaction managers, and some file systems.The basic idea is simple. Before performing an operation, a… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”