sstables: Handle empty counter value in read path
Due to a bug in an sstable writer, empty counters were stored without a header. Correct way of storing empty counter is to still write a header that indicates the emptiness. Next patch in this series fixes the write path but we have to make sure that we handle incorrectly serialized counters in the read path becuase there may exist sstables with counters stored without header. Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
This commit is contained in:
@@ -44,6 +44,14 @@ namespace sstables {
|
||||
atomic_cell make_counter_cell(api::timestamp_type timestamp, bytes_view value) {
|
||||
static constexpr size_t shard_size = 32;
|
||||
|
||||
if (value.empty()) {
|
||||
// This will never happen in a correct MC sstable but
|
||||
// we had a bug #4363 that caused empty counters
|
||||
// to be incorrectly stored inside sstables.
|
||||
counter_cell_builder ccb;
|
||||
return ccb.build(timestamp);
|
||||
}
|
||||
|
||||
data_input in(value);
|
||||
|
||||
auto header_size = in.read<int16_t>();
|
||||
|
||||
Reference in New Issue
Block a user