Skip to content

Commit

Permalink
sstables: throw at seeing invalid chunk_len
Browse files Browse the repository at this point in the history
before this change, when running into a zero chunk_len, scylla
crashes with `assert(chunk_size != 0)`. but we can do better than
printing a backtrace like:
```
scylla: sstables/compress.cc:158: void
sstables::compression::segmented_offsets::init(uint32_t): Assertion `chunk_size != 0' failed.
```
so, in this change, a `malformed_sstable_exception` is throw in place
of an `assert()`, which is supposed to verify the programming
invariants, not for identifying corrupted data file.

Fixes #15265
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #15264
  • Loading branch information
tchaikov authored and denesb committed Sep 6, 2023
1 parent 5930637 commit 1ed8941
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sstables/sstables.cc
Expand Up @@ -740,6 +740,9 @@ future<> parse(const schema& s, sstable_version_types v, random_access_reader& i
uint32_t chunk_len = 0;

co_await parse(s, v, in, c.name, c.options, chunk_len, data_len);
if (chunk_len == 0) {
throw malformed_sstable_exception("CompressionInfo is malformed: zero chunk_len");
}
c.set_uncompressed_chunk_length(chunk_len);
c.set_uncompressed_file_length(data_len);

Expand Down

0 comments on commit 1ed8941

Please sign in to comment.