batchlog_manager: Fix drain() reentrability

Currently drain() is called twise -- first time from
storage_service::drain() (on shutdown), second via
batchlog_manager::stop(). The routine is unintentinally re-entrable,
because:
- explicit check for not aborting the abort source twise
- breaking semaphore can be done multiple times
- co-await-ing of the _started future works because the future is shared

That's not extremely elegant, better to make the drain() bail out early
if it was already called.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2023-09-12 14:54:15 +03:00
parent bc4b3e4fa3
commit 38d0ea0916

View File

@@ -115,10 +115,12 @@ future<> db::batchlog_manager::start() {
}
future<> db::batchlog_manager::drain() {
blogger.info("Asked to drain");
if (!_stop.abort_requested()) {
_stop.request_abort();
if (_stop.abort_requested()) {
co_return;
}
blogger.info("Asked to drain");
_stop.request_abort();
if (this_shard_id() == 0) {
// Abort do_batch_log_replay if waiting on the semaphore.
_sem.broken();