From afa2ef6816ed90863543cf25d14c1cf18e534cd5 Mon Sep 17 00:00:00 2001 From: Wojciech Mitros Date: Wed, 29 Apr 2026 22:10:04 +0200 Subject: [PATCH] strong_consistency: skip read_barrier() for non-linearizable reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Non-linearizable reads (CL=ONE) no longer call read_barrier() before querying the local replica. This is safe because state_machine::apply() only writes to the table after raft commit, so a local read without read_barrier cannot see uncommitted data — just potentially stale data which is acceptable for CL=ONE semantics. --- service/strong_consistency/coordinator.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/service/strong_consistency/coordinator.cc b/service/strong_consistency/coordinator.cc index 76eb98207c..5546e59289 100644 --- a/service/strong_consistency/coordinator.cc +++ b/service/strong_consistency/coordinator.cc @@ -447,10 +447,12 @@ auto coordinator::query(schema_ptr schema, } // We're either a raft leader or it's a non-linearizable read. In both cases we can directly execute the read on this replica. - co_await utils::get_local_injector().inject("sc_coordinator_wait_before_query_read_barrier", - utils::wait_for_message(5min)); + if (rtype == read_type::linearizable) { + co_await utils::get_local_injector().inject("sc_coordinator_wait_before_query_read_barrier", + utils::wait_for_message(5min)); - co_await op.raft_server.server().read_barrier(&aoe.abort_source()); + co_await op.raft_server.server().read_barrier(&aoe.abort_source()); + } auto [result, cache_temp] = co_await _db.query(schema, cmd, query::result_options::only_result(), ranges, trace_state, timeout);