Cassandra commitlog plays a role in restoration

Source: Internet
Author: User
Tags cassandra

The newly written dirty data is in the memory memtable table. Therefore, you must have an organic mechanism to ensure that the data in the memory can be restored in case of exceptions. And relational database system 1
Example: Cassandra also uses the method of first writing logs and then writing data. Its logs are called commitlog.

Unlike memtable/sstable,Commitlog is server-level, not column family-level
.
The size of each commitlog file is fixed.
Segment, in the current version (0.5.1), the size is 128 MB, which is hard-coded in the Code (src/Java/org/Apache/cassandra
In/DB/commitlog. Java. When a commitlog file is full, a new file is created. When the old commitlog file is no longer needed
.

Each commitlog file (segment) has a fixed size (size depends on the number of column families ).Commitlogheader
End
Structure, which has two important arrays. Each column family has a corresponding element in the two arrays. One of them is a bitmap array (Bitset
Dirty

), If Column
If the memtable corresponding to family has dirty data, it is set to 1; otherwise, it is 0. Which columns can be pointed out during recovery?
Family must be restored using commitlog. The other is an integer array (Int [] lastflushedat
),
Column is saved.
The offset position of the log during the last flush operation. The commitlog record can be read from this position during recovery. With these two array structures, Cassandra can
During service restart, memtable content in the memory is reconstructed based on the persistent sstable and commitlog, that is, instance recovery for relational databases such as oracle.

When memtable
When flush to the sstable of the disk, the bitwise corresponding to the dirty array of all commitlog files is cleared, and a new file is created when the commitlog size limit is reached.
The dirty array is inherited from the previous file. If all the dirty arrays of A commitlog file are cleared, this indicates that the commitlog is not restored.
And can be cleared. Therefore, the commitlog files on all disks are required during recovery.

 

From http://www.ningoo.net/html/2010/cassandra_commitlog.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.