3. Database Buffering contd..
• Advantages of no-force policy:
Faster commit of transaction.
Reduce the number of output operations
to disk.
4. Database Buffering contd..
• No-Steal policy:
– Blocks modified by a transaction that is still active
should not be written to disk.
• Steal-policy:
Modified blocks written to disk even if
transaction has not committed.
5. Database Buffering contd..
• Disadvantage of no-steal policy:
Buffer may be full of updated pages which
cannot be written to disk.
6. Database Buffering contd..
Steal policy needs to implement write-ahead logging(WAL)
rule.
• Ti enters commit state after <Ti commit> log record has
been o/p to stable storage
• Before <Ti commit> log record can be o/p to stable storage,
all log records pertaining to transaction Ti must have been
o/p to stable storage
• Before a block of data in main memory can be o/p to
database, all log records pertaining to data in that block
must have been o/p to stable storage
7. Database Buffering contd..
Example showing the need for WAL rule:
Let To be a transaction that transfers Rs.50
from account A to B
To :
read(A);
A:=A-50;
Write(A);
read(B);
B:=B+50;
write(B);
9. Database Buffering contd..
• Suppose state of the log is:
<T0 start>
<T0, A, 1000,950>
To issues a read(B).
B is not in memory and memory is full.
A is output to disk and system crash.
A-950,B-2000 -->inconsistent.
But using WAL rule it will not be inconsistent.
10. Database Buffering contd..
• No write to the block when the block is being output to
disk.
Lock the block when a write operation is in process. Then
released when done.
• When a block is output,no write operation is
performed.
These are ensured by special means of locking.
– Lock the block.
– log records to stable storage.
– Output block to disk.
– Release the lock.
11. Database Buffering contd..
• Latches:
Locks that are held for short duration.
• Locks are also needed when checkpoint is
in progress.