From fb1d3fe2cf41a72190846dde85e3ebd00e6eb4b3 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Mon, 22 Feb 2021 16:31:49 +0100 Subject: [PATCH] table: Fix schema mismatch between memtable reader and sstable writer The schema used to create the sstable writer has to be the same as the schema used by the reader, as the former is used to intrpret mutation fragments produced by the reader. Commit 9124a70 intorduced a deferring point between reader creation and writer creation which can result in schema mismatch if there was a concurrent alter. This could lead to the sstable write to crash, or generate a corrupted sstable. Fixes #7994 Message-Id: <20210222153149.289308-1-tgrabiec@scylladb.com> --- table.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/table.cc b/table.cc index a76b48fa47..416881a65e 100644 --- a/table.cc +++ b/table.cc @@ -1698,7 +1698,8 @@ write_memtable_to_sstable(flat_mutation_reader reader, cfg.replay_position = mt.replay_position(); cfg.monitor = &monitor; cfg.origin = "memtable"; - return sst->write_components(std::move(reader), mt.partition_count(), mt.schema(), cfg, mt.get_encoding_stats(), pc); + schema_ptr s = reader.schema(); + return sst->write_components(std::move(reader), mt.partition_count(), s, cfg, mt.get_encoding_stats(), pc); } future<>