I am studying zookeeper, so I read the paper "A simple totally ordered broadcast protocol". And I dont really understand the following sentence:
"ZooKeeper uses an in-memory database and stores transaction logs and periodic snapshots on disk. Zab’s transaction log doubles as the database write-ahead transaction log so that a transaction will only be written to the disk once."
Is there anyone can explain it to me?
A transaction log is used to record the fact that a transaction is set to occur as well as the information needed by the database server to recover the data back to a consistent state in event of a sever failure while it is writing information to disk.
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.
Overview. The ZooKeeper Data Directory contains snapshot and transactional log files which are persistent copy of the znodes stored by an ensemble. Any changes to znodes are appended to transaction log and when the log file size increases, a snapshot of the current state of znodes is written to the filesystem.
Zookeeper needs to write transactions to disk, otherwise if you restart zookeeper, it would forget about any transasctions it has heard. The way zookeeper writes to disk, is that before zookeeper responds to a transaction, it will append the transaction to a transaction log file. When the transaction log file reaches a certain size, a new transaction log file is created.
Writing to transaction log files is not efficient by itself, since on startup zookeeper would have to replay every transaction it ever processed. So periodically, zookeeper will write a snapshot of the current state of its in memory database to file. Then when starting up, zookeeper only has to load the snapshot, and any transaction logs since the snapshot was created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With