Adbms CH 1.c
Adbms CH 1.c
transaction execution.
Transaction error: some operation [e.g. Div by 0] in the transaction
Main memory buffers hold the last part of the log file
The log entries are first added to the main memory buffer. When
the main memory(MM) log buffer is filled, or when certain other
conditions occur, the MM log buffer is appended to the end of
the log file on disk.
In addition, the log file from disk is periodically backed up to
archival storage (tape) to guard against catastrophic failures.
Types of Entries (Log Records)
A transaction T reaches its commit point when all its operations that access the
database have been executed successfully and the effect of all the transaction
operations on the database have been recorded in the log
- If a system failure occurs, we can search back in the log for all transactions T that
have written a [start_transaction, T] record into the log but have not written their
[commit, T] record yet; these transactions may have to be rolled back to undo their
effect on the database during the recovery process.
- Transactions that have written their commit record in the log must also have
recorded all their WRITE operations in the log, so their effect on the database can
be redone from the log records.
Commit Point of a Transaction
One or more blocks of the log file is kept in main memory buffers
called the log buffer,
The log buffer entries is write back to disk only once when the log
buffer filled with log entries, rather than writing to disk every time
a log entry is added, i.e saving the overhead of multiple disk writes.
Therefore, before a transaction reaches its commit point, any portion
of the log that has not been written to the disk yet must now be
written to the disk.
This process is called force-writing the log buffer before
committing a transaction.
Caching (Buffering) of Disk Blocks
No-steal approach
A cache page updated by a transaction cannot be written to
disk before the transaction commits.
Deferred update follows this approach.
The pin-unpin bit indicates if a page cannot be written
back to disk
Cont’d
Steal approach
An updated buffer can be written to disk before the
transaction commits.
Used when the buffer manager replaces an existing page in
the cache, that has been updated by a transaction not yet
committed, by another page requested by another transaction.
Advantage: avoid the need for a very large buffer space.
Cont’d
Force approach
All pages updated by a transaction are immediately written
to disk before the transaction commits.
Cont’d
No-Force approaches
All pages updated by a transaction are not immediately
written to disk when the transaction commits.
Advantage: an updated page of a committed transaction may
be still in the buffer when another transaction needs to update
it; saving I/O cost.
Main Recovery Techniques
Assume
- Log includes checkpoints.
- Strict 2PL concurrency control protocol is used.
1. Identify two lists for a transaction. A list of committed
transaction since last checkpoint and a list of active
transactions.
2. Apply the REDO operation to all the write_item operations of
the committed transaction from the log in the order in which
they were written to the log.
Cont’d
Assume
- Log includes checkpoints.
- Strict 2PL concurrency control protocol is used.
4. REDO is more efficiently done by starting from the end of the log
and redoing only the last update of each item X.