Skip to content

Commit

Permalink
multishard_mutation_query: make multi_range_reader::fill_buffer() wor…
Browse files Browse the repository at this point in the history
…k even after EOS

if fill_buffer() is called after EOS, underlying reader will
be fast forwarded to a range pointed to by an invalid iterator,
so producing incorrect results.

fill_buffer() is changed to return early if EOS was found,
meaning that underlying reader already fast forwarded to
all ranges managed by multi_range_reader.

Usually, consume facilities check for EOS, before calling
fill_buffer() but most reader impl check for EOS to avoid
correctness issues. Let's do the same here.

Signed-off-by: Raphael S. Carvalho <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
raphaelsc authored and denesb committed Dec 8, 2021
1 parent f285520 commit c3c23dd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions multishard_mutation_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ class multi_range_reader : public flat_mutation_reader::impl {
: impl(std::move(s), std::move(permit)) , _reader(std::move(rd)) , _it(ranges.begin()) , _end(ranges.end()) { }

virtual future<> fill_buffer() override {
if (is_end_of_stream()) {
co_return;
}
while (is_buffer_empty()) {
if (_reader.is_buffer_empty() && _reader.is_end_of_stream()) {
if (++_it == _end) {
Expand Down

0 comments on commit c3c23dd

Please sign in to comment.