What is the purpose of the Commit Log?
Last updated
The commit log is Cassandra's crash-recovery mechanism: every write is appended to it on disk before (or as) it goes into the in-memory memtable, so no acknowledged write is lost if the node crashes before the data is flushed to an SSTable.
Durability guarantee:
A write is appended to the commit log and applied to the memtable; only then is it acknowledged.
If the node dies before the memtable is flushed, the commit log is replayed on restart to rebuild the lost memtable state.
Sequential, append-only writes: Appends are fast because they avoid random disk seeks, which is a key reason Cassandra writes are cheap.
Segments and cleanup: The log is split into segments; once all data in a segment has been flushed to SSTables, that segment can be discarded/recycled.
Sync modes:
periodic(default): fsync on an interval, faster but a tiny window of risk;batch/group: fsync before acking, safer but slower.
- https://cassandra.apache.org/_/blog/Learn-How-CommitLog-Works-in-Apache-Cassandra.html
- https://axonops.com/docs/data-platforms/cassandra/architecture/storage-engine/commitlog/
- https://aicassindra.com/blogs/cassandra/cassandra_commit_log.html
- https://cassandra.apache.org/doc/4.0/cassandra/architecture/storage_engine.html
- https://cassandra.apache.org/doc/stable/cassandra/architecture/storage-engine.html
- https://medium.com/@iayushpandey/understanding-cassandras-storage-engine-sstables-memtables-and-commit-logs-9f634aaadf1d
- https://www.hellointerview.com/learn/system-design/deep-dives/cassandra
- https://www.geeksforgeeks.org/nosql/apache-cassandra-interview-questions-2/