开发者

What does cassandra do during compaction?

开发者 https://www.devze.com 2023-04-10 20:20 出处:网络
I know that cassandra merges sstables, row-keys,remove tombstone and all. But i am really interested to know how it performs compaction ?

I know that cassandra merges sstables, row-keys, remove tombstone and all.

  1. But i am really interested to know how it performs compaction ?

  2. As sstables are immutable does it copy all the relevant data to new file? and while writing to this new file it discard the tombstone m开发者_如何学运维arked data.

i know what compaction does but want to know how it make this happen(T)


I hope this thread helps, provided if you follow all the posts and comments in it

http://comments.gmane.org/gmane.comp.db.cassandra.user/10577

AFAIK

Whenever memtable is flushed from memory to disk they are just appended[Not updated] to new SSTable created, sorted via rowkey.
SSTable merge[updation] will take place only during compaction. 
Till then read path will read from all the SSTable having that key you look up and the result from them is merged to reply back,

Two types : Minor and Major

Minor compaction is triggered automatically whenever a new sstable is being created.
May remove all tombstones
Compacts sstables of equal size in to one [initially memtable flush size] when minor compaction threshold is reached [4 by default]. 

Major Compaction is manually triggered using nodetool
Can be applied over a column family over a time
Compacts all the sstables of a CF in to 1

Compacts the SSTables and marks delete over unneeded SSTables. GC takes care of freeing up that space

Regards, Tamil


Are two ways to run compaction :

A- Minor compaction. Run automatically. B- Major compaction. Run mannualy.

In both cases takes x files (per CF) and process them. In this process mark the rows with expired ttl as tombstones, and delete the existing tombstones. With this generates a new file. The tombostones generated in this compaction, will be delete in the next compaction (if spend the grace period, gc_grace).

The difference between A and B are the quantity of files taken and the final file. A takes a few similar files (similar size) and generate a new file. B takes ALL the files and genrate only one big file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号