ArticleslgStudy

computer science

Transaction log

Transaction log is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Transaction log rather than just read about it. In short: In the field of databases in computer science, a transaction log (also transaction journal, database log, binary log or audit trail) is a history of actions executed by a database management system used to guarantee ACID properties over crashes or hardware failures. Physically, a log is a file listing changes to the database, stored in a stable storage format.

Key takeaways

  • Transaction log belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Transaction log to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Transaction log from memory before moving on to harder problems.

Reference excerpt

In the field of databases in computer science, a transaction log (also transaction journal, database log, binary log or audit trail) is a history of actions executed by a database management system used to guarantee ACID properties over crashes or hardware failures. Physically, a log is a file listing changes to the database, stored in a stable storage format. 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. In database management systems, a journal is the record of data altered by a given process.

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 algorithms, like ARIES. Prev LSN: A link to their 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 (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), 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 Error correction and detection Hash function Journaling file system Log-structured file system Write-ahead logging Redo log

Sources Federal Standard 1037C

References

Worked examples

Example 1 — a first encounter with Transaction log

Start with the simplest possible case. Write down what Transaction log claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Transaction log before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Transaction log ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Transaction log

In research
Transaction log appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Transaction log in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Transaction log is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer logging, Database management systems, Transaction processing, so understanding it makes those chapters shorter.
In everyday life
Look for Transaction log outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Transaction log” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Transaction log in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Transaction log means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Transaction log out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Transaction log in simple terms?

In the field of databases in computer science, a transaction log (also transaction journal, database log, binary log or audit trail) is a history of actions executed by a database management system used to guarantee ACID properties over crashes or hardware failures. Physically, a log is a file list…

Why does Transaction log matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Transaction log?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Transaction log.

Tags

  • Computer logging
  • Database management systems
  • Transaction processing

Keep exploring