From 2308bdbccbb1a1072c88ef4cdc8f7f292a35bb3b Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Thu, 16 Apr 2020 12:04:41 +0200 Subject: [PATCH] alternator: use partition tombstone if there's no clustering key As @tgrabiec helpfully pointed out, creating a row tombstone for a table which does not have a clustering key in its schema creates something that looks like an open-ended range tombstone. That's problematic for KA/LA sstable formats, which are incapable of writing such tombstones, so a workaround is provided in order to allow using KA/LA in alternator. Fixes #6035 Cherry-picked from 0a2d7addc0cd44ab6d8b6a957769e42a3c9ccf75 --- alternator/executor.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/alternator/executor.cc b/alternator/executor.cc index d79a51b22c..4a79bec04d 100644 --- a/alternator/executor.cc +++ b/alternator/executor.cc @@ -731,7 +731,12 @@ static mutation make_item_mutation(const rjson::value& item, schema_ptr schema) // Scylla proper, to implement the operation to replace an entire // collection ("UPDATE .. SET x = ..") - see // cql3::update_parameters::make_tombstone_just_before(). - row.apply(tombstone(ts-1, gc_clock::now())); + const bool use_partition_tombstone = schema->clustering_key_size() == 0; + if (use_partition_tombstone) { + m.partition().apply(tombstone(ts-1, gc_clock::now())); + } else { + row.apply(tombstone(ts-1, gc_clock::now())); + } return m; } @@ -802,8 +807,13 @@ static mutation make_delete_item_mutation(const rjson::value& key, schema_ptr sc clustering_key ck = ck_from_json(key, schema); check_key(key, schema); mutation m(schema, pk); - auto& row = m.partition().clustered_row(*schema, ck); - row.apply(tombstone(api::new_timestamp(), gc_clock::now())); + const bool use_partition_tombstone = schema->clustering_key_size() == 0; + if (use_partition_tombstone) { + m.partition().apply(tombstone(api::new_timestamp(), gc_clock::now())); + } else { + auto& row = m.partition().clustered_row(*schema, ck); + row.apply(tombstone(api::new_timestamp(), gc_clock::now())); + } return m; }