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.
This commit is contained in:
Botond Dénes
2021-05-04 14:36:36 +03:00
parent 41181a5c2f
commit ba75115e20

View File

@@ -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();