A sequential journal of database write operations that facilitates robust atomic write operations.
Transaction logs are a journalling mechanism employed by the database manager for atomic and consistent write functionality. They are written sequentially, indexed by a sequence number (Log Sequence number, or LSN) and contain a journal of database write operations. Depending on the implementation the logs may also contain rollback information.
The logs contain data about the changes to be made by pending transactions and markers for commit and checkpoint operations. Log information is always recorded before a transaction is committed, and commit entries are not recorded in the log until the changes have been persisted.
Database writes will typically generate entries that are immediately written to the logs and the write will also update entries in the buffer cache. Only one transaction can have a write lock on a record at any given point, so other processes will block on attempts to obtain a lock on that record. Periodic checkpoint operations flush dirty pages to disk.
Logs can be used for recovery and replication. A database is always backed up with respect to the log sequence number of the last committed transaction. If the data file is restored then logs can be rolled forward from the commit point to apply all transactions committed since that point. A similar mechanism is used for replication where log entries are copied and applied to the database on the replication target.