From ba75115e2072cc2f3031a8cb6dece7ccdae95a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Tue, 4 May 2021 14:36:36 +0300 Subject: [PATCH] sstables: compaction/scrub: prevent infinite loop when last partition end is missing Scrub compaction will add the missing last partition-end in a stream when allowed to modify the stream. This however can cause an infinite loop: 1) user calls fill_buffer() 2) process fragments until underlying is at EOS 3) add missing partition end 4) set EOS 5) user sees that last buffer wasn't empty 6) calls fill_buffer() again 7) goto (3) To prevent this cycle, break out of `fill_buffer()` early when both the scrub reader and the underlying is at EOS. --- sstables/compaction.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sstables/compaction.cc b/sstables/compaction.cc index b200bb968f..096791c490 100644 --- a/sstables/compaction.cc +++ b/sstables/compaction.cc @@ -1277,6 +1277,9 @@ class scrub_compaction final : public regular_compaction { , _validator(*_schema) { } virtual future<> fill_buffer(db::timeout_clock::time_point timeout) override { + if (_end_of_stream) { + return make_ready_future<>(); + } return repeat([this, timeout] { return _reader.fill_buffer(timeout).then([this] { fill_buffer_from_underlying();