Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

confused about transaction logs in zookeeper

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?

like image 654
Snail Avatar asked Feb 16 '14 08:02

Snail


People also ask

What are transaction logs used for?

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.

What is transaction log database?

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.

What are snapshots in zookeeper?

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.


1 Answers

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.

like image 148
sbridges Avatar answered Sep 21 '22 06:09

sbridges