sstables: fix load_metadata to check S3 for scylla metadata component

sstable_stream_sink_impl::load_metadata() used file_exists() on a
local filesystem path to check whether the Scylla metadata component
exists. For S3-backed storage this always returns false because the
file lives on object storage, not locally.

This means that when streaming encrypted SSTables, each component
gets a fresh encryption key (because the previous key from scylla
metadata is never loaded). Only the last key survives in the metadata
on S3, so all other components become unreadable — decryption with the
wrong key produces garbage, leading to parse failures or OOM crashes
on sst->load().

Replace file_exists() with _sst->_storage->exists() which correctly
checks for the component on whatever backend the SSTable uses (local
filesystem or object storage).

Fixes https://scylladb.atlassian.net/browse/SCYLLADB-1704
This commit is contained in:
Ernest Zaslavsky
2026-05-05 16:29:57 +03:00
parent a3d07a468f
commit 54571ffacb

View File

@@ -4281,8 +4281,7 @@ public:
{}
private:
future<> load_metadata() const {
auto metafile = _sst->filename(sstables::component_type::Scylla);
if (!co_await file_exists(fmt::to_string(metafile))) {
if (!co_await _sst->_storage->exists(*_sst, component_type::Scylla)) {
// for compatibility with streaming a non-scylla table (no scylla component)
co_return;
}