From 98652a87f381524fb50cc890f3ac524711952507 Mon Sep 17 00:00:00 2001 From: Michal Maslanka Date: Wed, 30 Aug 2023 12:23:06 +0200 Subject: [PATCH] r/consensus: wait for follower responses to take effect Grab `_op_lock` in `consensus::lineraizable_barrier` to wait for follower replies to take effect. This makes linearizable_barrier more strict as before returning result leader waits for the follower replies to be processed. Signed-off-by: Michal Maslanka --- src/v/raft/consensus.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/v/raft/consensus.cc b/src/v/raft/consensus.cc index 13985917dec98..d059a4bb253f7 100644 --- a/src/v/raft/consensus.cc +++ b/src/v/raft/consensus.cc @@ -708,7 +708,9 @@ ss::future> consensus::linearizable_barrier() { } catch (const ss::broken_condition_variable& e) { co_return ret_t(make_error_code(errc::shutting_down)); } - + // grab an oplock to serialize state updates i.e. wait for all updates in + // the state that were caused by follower replies + auto units = co_await _op_lock.get_units(); // term have changed, not longer a leader if (term != _term) { co_return ret_t(make_error_code(errc::not_leader));