Reliability manager
Responsible for atomicity and durability 2 of the ACID propertries.
Implements these transactional commands:
Recovery primitives:
Interacts with buffer manager to ensure read/write requests’ reliability, and may generate more read/write requests for reliability purposes.
It exploit log file: a log of the DBMS activity stored in stable memory.
It prepares data for recovery by using: checkpoints and dumps.
ACID
Atomicity: changes on multiple data points are made as it was just one operation. -> either all changes are performed or none.
Consistency: any change must be consistent with the rules (from constraints, triggers, cascades). I.E. to avoid to create money out of thin air (in banks)
Isolation: every transaction is executed in a isolated and indipendent way.
Durability: after the transaction is committed the changes endure.
Stable memory
Memory that is resistant to failure:
Failures in stable memory are THE END OF THE F*CKING WORLD (catastrophic).
Log file
Records transaction activities in chronological order.
Two types of record:
Writing:
Undo/Redo
Undo
Insert O -> delete O
update O -> write the before state of O
delete O -> write BS of O
Redo
insert O -> write AS of O
update O -> write AS of O
delete O -> delete O
Idempotency property:
Undo or Redo can be applied an arbitrary number of times without chaning the outcome. -> UNDO(UNDO(ACTION)) = UNDO(ACTION)
REDO(REDO(REDO(REDO(A)))) = REDO(REDO(A))
Checkpoint
Operation periodically requested by Reliability manager to buffer manager.
Duing checkpoint the dbms: writes data of committed and aborted transactions on disk (sync. write with force primitive) and records the set of active transactions. After this the chekpoint record is written (using force primitive) on log containing set of active transactions.
After the checkpoint, all committed transactions are permanently stored on disk.
DUMP
It creates a complete copy of the state of the database:
At the end of the dump, a dump record is written in the log file:
Writing the log: rules
WAL: WRITE AHEAD LOG
Commit precedence
In practice:
Commit record on the log is a milestone:
Writing the log guaranteeing properties
Usage of robust protocols to guarantee reliability is costly.
It is require to guarantee the ACID properties.
Log writing is optimized through: compact format, parallelism and commit of groups of transactions.
Protocols for writing log and database

Types of failures
Part of recovery management
System failure:
Media failure:
Fail-stop model and recovery
Failure -> system stop
Recovery depends on failure type:
When recovery end the systems becomes again available to perform transactions

Warm Restart, Transaction categories
Checkpoint records is not really needed to enable recovery, but provedies faster warm restart. Without checkpoint record needs to be readh from last dump.
Algo:

Warm restart algorithm
Algo:
Cold Restart
Manages failures demaging (a portion of) the database on disk
Steps
Alternative to 2 and 3 are:
Buffer manager and place within DBMS architecture
Manages page transfer from disk to main memory and vice versa.
It is in charge of managing the DBMS buffer.
Efficient buffer management is crucial for DBMS perfomance.
Buffer: A large block of main memory pre-allocated to the DBMS, that is shared among executing transactions.
Buffer organization: Memory is organized in pages, the size of a page depends on the size of the operating system I/O block.

Memory management strategies used by buffer manager
Buffer manager keeps additional snapshop information on the current content of the buffer.
For each buffer page
Primitives to access/load pages from disk and v.c.:
The buffer manager requires shared access premission from the concurrency control manager.

Buffer manger: fix primitive
Used by transactions to require access to disk:
At the end of the fix primitive the requested page:
The fix primitive requires an I/O operation only if the requeste page is not yet in the buffer, if it finds the requested already in the buffer, it returins to the requesting transaction the address of the page in the buffer (this, because of data locality, happens often enough).
If the page is not inside the buffer, a lookup must reveal a page where the new page can be loaded, first among free pages, next among pages which are not free, but with count = 0 (called victing page, may still be locks, if the page has dirty=1, it is written synchronously on disk)
Buffer manager: unfix primitive
Tells the buffer manger that the transaction is not using the page anymore: state variable Count is decremented by 1.
Buffer manager: set dirty primitive
It tells the buffer manager that the page has been modified by the running transaction: dirty = 1
Buffer manager: force primitive
It requires a synchronous transfer of the page to disk: requesting transactions is stopped until the primitive ends.
It always entails a disk write.
Buffer manager: flush primitive
It transfers pages to disk, independently of transaction requests:
Buffer manager: writing strategies
Typical strategy combines steal and no force, because of its efficiency:
Buffer manager use of Filesystem