mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-03 21:47:10 +00:00
sstables: parse statistics: improve error handling
Properly return malformed_sstable_exception if the statistics file fails to parse. Test: unit(dev) Signed-off-by: Benny Halevy <bhalevy@scylladb.com> Message-Id: <20210524113808.973951-1-bhalevy@scylladb.com>
This commit is contained in:
@@ -632,18 +632,25 @@ future<> parse(const schema& schema, sstable_version_types v, random_access_read
|
||||
return parse<stats_metadata>(schema, v, in, s.contents[type]);
|
||||
case metadata_type::Serialization:
|
||||
if (v < sstable_version_types::mc) {
|
||||
throw std::runtime_error(
|
||||
throw malformed_sstable_exception(
|
||||
"Statistics is malformed: SSTable is in 2.x format but contains serialization header.");
|
||||
} else {
|
||||
return parse<serialization_header>(schema, v, in, s.contents[type]);
|
||||
}
|
||||
return make_ready_future<>();
|
||||
default:
|
||||
sstlog.warn("Invalid metadata type at Statistics file: {} ", int(type));
|
||||
return make_ready_future<>();
|
||||
throw malformed_sstable_exception(fmt::format("Invalid metadata type at Statistics file: {} ", int(type)));
|
||||
}
|
||||
});
|
||||
});
|
||||
}).handle_exception([] (std::exception_ptr ex) {
|
||||
try {
|
||||
std::rethrow_exception(ex);
|
||||
} catch (const malformed_sstable_exception&) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
throw malformed_sstable_exception(fmt::format("Statistics file is malformed: {}", ex));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user