Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

gmldba_107428 avatar image
gmldba_107428 asked ·

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 characters needed characters left characters exceeded

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 characters needed characters left characters exceeded

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

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 characters needed characters left characters exceeded

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 ·

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 characters needed characters left characters exceeded

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

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

0 Likes 0 · ·