In the field of
database
In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases sp ...
s in
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, a transaction log (also transaction journal, database log, binary log or audit trail) is a history of actions executed by a
database management system
In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases span ...
used to guarantee
ACID
In computer science, ACID ( atomicity, consistency, isolation, durability) is a set of properties of database transactions intended to guarantee data validity despite errors, power failures, and other mishaps. In the context of databases, a sequ ...
properties over
crash
Crash or CRASH may refer to:
Common meanings
* Collision, an impact between two or more objects
* Crash (computing), a condition where a program ceases to respond
* Cardiac arrest, a medical condition in which the heart stops beating
* Couch su ...
es or hardware failures. Physically, a log is a
file
File or filing may refer to:
Mechanical tools and processes
* File (tool), a tool used to ''remove'' fine amounts of material from a workpiece
**Filing (metalworking), a material removal process in manufacturing
** Nail file, a tool used to gent ...
listing changes to the database, stored in a stable storage format.
If, after a start, the database is found in an
inconsistent
In classical deductive logic, a consistent theory is one that does not lead to a logical contradiction. The lack of contradiction can be defined in either semantic or syntactic terms. The semantic definition states that a theory is consistent ...
state or not been shut down properly, the database management system reviews the database logs for
uncommitted
''Uncommitted'' is XIA's first single. It consists of title track "Uncommitted" and an oriental version of the title song of his first Korean studio album ''Tarantallegra'', which was released earlier in 2012. Both songs on this single are sung i ...
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
Durability is the ability of a physical product to remain functional, without requiring excessive maintenance or repair, when faced with the challenges of normal operation over its design lifetime. There are several measures of durability in use, ...
of transactions.
This term is not to be confused with other, human-readable
logs that a database management system usually provides.
In
database management system
In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases span ...
s, a journal is the record of data altered by a given process.
neurobs.com, Logfiles
/ref>
Anatomy of a general database log
A database log record is made up of:
*''Log Sequence Number'' (LSN): A unique ID for a log record. With LSNs, logs can be recovered in constant time. Most LSNs are assigned in monotonically increasing order, which is useful in recovery algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algorithms are used as specificat ...
s, like ARIES
Aries may refer to:
*Aries (astrology), an astrological sign
*Aries (constellation), a constellation of stars in the zodiac
Arts, entertainment and media
* ''Aries'' (album), by Luis Miguel, 1993
* ''Aries'' (EP), by Alice Chater, 2020
* "Aries" ...
.
*''Prev LSN'': A link to their last log record. This implies database logs are constructed in linked list
In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes whic ...
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 (CLR) notes the rollback of a particular change to the database. Each corresponds 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 roll back 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
PostgreSQL (, ), also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. It was originally named POSTGRES, referring to its origins as a successor to the In ...
), 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)
See also
*Data logging
A data logger (also datalogger or data recorder) is an electronic device that records data over time or about location either with a built-in instrument or sensor or via external instruments and sensors. Increasingly, but not entirely, they ar ...
*Error correction and detection
In information theory and coding theory with applications in computer science and telecommunication, error detection and correction (EDAC) or error control are techniques that enable reliable delivery of digital data over unreliable communi ...
*Hash function
A hash function is any function that can be used to map data of arbitrary size to fixed-size values. The values returned by a hash function are called ''hash values'', ''hash codes'', ''digests'', or simply ''hashes''. The values are usually u ...
*Journaling file system
A journaling file system is a file system that keeps track of changes not yet committed to the file system's main part by recording the goal of such changes in a data structure known as a "journal", which is usually a circular log. In the even ...
*Log-structured file system
A log-structured filesystem is a file system in which data and metadata are written sequentially to a circular buffer, called a log. The design was first proposed in 1988 by John K. Ousterhout and Fred Douglis and first implemented in 1992 by Ou ...
*Write-ahead logging
In computer science, write-ahead logging (WAL) is a family of techniques for providing atomicity and durability (two of the ACID properties) in database systems. A write ahead log is an append-only auxiliary disk-resident structure used for crash ...
*Redo log
Undo is an interaction technique which is implemented in many computer programs. It erases the last change done to the document, reverting it to an older state. In some more advanced programs, such as graphic processing, undo will negate the las ...
Sources
*Federal Standard 1037C
Federal Standard 1037C, titled Telecommunications: Glossary of Telecommunication Terms, is a United States Federal Standard issued by the General Services Administration pursuant to the Federal Property and Administrative Services Act of 1949, a ...
References
{{DEFAULTSORT:Transaction Log
Database management systems
Transaction processing
Computer logging