diff --git a/sstables/compaction.cc b/sstables/compaction.cc index 8eff060c0c..66b140eb12 100644 --- a/sstables/compaction.cc +++ b/sstables/compaction.cc @@ -212,16 +212,18 @@ public: }; struct compaction_writer { + shared_sstable sst; // We use a ptr for pointer stability and so that it can be null // when using a noop monitor. sstable_writer writer; // The order in here is important. A monitor must be destroyed before the writer it is monitoring since it has a // periodic timer that checks the writer. + // The writer must be destroyed before the shared_sstable since the it may depend on the sstable + // (as in the mx::writer over compressed_file_data_sink_impl case that depends on sstables::compression). std::unique_ptr monitor; - shared_sstable sst; compaction_writer(std::unique_ptr monitor, sstable_writer writer, shared_sstable sst) - : writer(std::move(writer)), monitor(std::move(monitor)), sst(std::move(sst)) {} + : sst(std::move(sst)), writer(std::move(writer)), monitor(std::move(monitor)) {} compaction_writer(sstable_writer writer, shared_sstable sst) : compaction_writer(nullptr, std::move(writer), std::move(sst)) {} };