question

gmldba_107428 avatar image
gmldba_107428 asked Cedrick Lunven answered

Will updating records create tombstones?

When updating a record, Cassandra just creates a new record with a more recent timstamp. Will the old record be marked as tombstone?

cassandratombstones
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered

@gmldba_107428 No, it doesn't create tombstones. When a row is updated, Cassandra just inserts a new row to the database without checking if a duplicate row already exists -- C* doesn't do read-before-write.

At read time, C* compares all the versions of the row if there is more than one and only returns the latest version of the row. The "latest version" being the one with the newest timestamp. Similarly at compaction time, only the newest version of the row gets written to the new SSTable and all the obsolete/out-of-date versions of the row are dropped, effectively getting deleted or compacted out.

For more details, see How data is updated in the DataStax Docs. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

ben.krug_85176 avatar image
ben.krug_85176 answered Erick Ramirez commented

To add to Erick's answer, there are a couple of exceptions - certain updates to collection data types (sets, lists, etc) will generate tombstones, and updates that affect a materialized view can generate tombstones in the materialized view. (Also, TTLs that expire generate tombstones.) . See the docs here for more details.

1 comment Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image Erick Ramirez ♦♦ commented ·

Thanks @ben.krug_85176. Those are very good points indeed. Cheers!

0 Likes 0 ·
Cedrick Lunven avatar image
Cedrick Lunven answered

In addition I think about 2 more use cases :

  • INSERT STATEMENTS with explicit `null` in columns values (insert are upsert and as such can update)
  • Updating the TTL in a row would also create a tombstone


Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.