From ee193f1ab44e1fa93475d0db4e451ca46e691c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Thu, 6 Dec 2018 10:53:19 +0200 Subject: [PATCH] multishard_combining_reader: pause readers after reading ahead Readers created or resumed just to read ahead should be paused right after, to avoid consuming all available permits on the shards they operate on, causing a deadlock. --- mutation_reader.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mutation_reader.cc b/mutation_reader.cc index bce18cf3c3..c89e3557ca 100644 --- a/mutation_reader.cc +++ b/mutation_reader.cc @@ -1309,7 +1309,12 @@ void multishard_combining_reader::shard_reader::read_ahead(db::timeout_clock::ti if (state->stopped) { return make_ready_future<>(); } - return do_fill_buffer(timeout); + return do_fill_buffer(timeout).then([this, state = std::move(state)] { + // Read ahead is still in the background, so pause the reader. + if (!state->stopped && _read_ahead) { + pause(); + } + }); })); }