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 0a2d7addc0
This commit is contained in:
Piotr Sarna
2020-04-16 12:04:41 +02:00
parent a2d39c9a2e
commit 2308bdbccb

View File

@@ -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;
}