bala
bala

Reputation: 333

Will Minor Compactions in Cassandra remove elapsed TTL records

Below is the table schema i am using. Cassandra version is 2.1

CREATE TABLE metadata ( customerid int, user text, messageid text, subject text, PRIMARY KEY ((customerid, user), messageid) ) WITH CLUSTERING ORDER BY (messageid ASC) AND compaction = {'class':'org.apache.cassandra.db.compaction.LeveledCompactionStrategy', 'sstable_size_in_mb' : '4'} AND gc_grace_seconds = 172800 ;

For the same (customerid,user) records would get inserted continuously. While inserting we set TTL which would be minimum 14 days and would be always greater than gc_grace_seconds.

No updates or deletion happens .

For the same (customerid, user) we could have data in multiple SSTable files.

While LCS compaction runs, would it drop records which have elapsed even if other SSTable files that are not being compacted have data for the same partition key. In one of the cassandra mail archives I read ,

"Tombstones will be expired by Minor Compaction if all fragments of the row are contained in the SSTables being compacted."

Is this applicable for data with TTL also?

Upvotes: 1

Views: 295

Answers (1)

You will insert an entire row for the table "metadata". As you mentioned that there are no updates and manual deletes, the entire row should reside in only one SSTable. So while minor compaction, the respective row will be removed from SSTable.

FYI, your TTL is 14 days. Your data will be marked as tombstones after 14 days. Your gc_grace_seconds is 172800 (2 days). So the tombstone will exist for next 2 days. So once 16 days are expired from the beginning, the next minor or major compaction will remove the data.

Upvotes: 0

Related Questions