From 65d9655eee5bc56506e8afb5a02bd0926d90c76b Mon Sep 17 00:00:00 2001 From: Michal Maslanka Date: Fri, 29 Sep 2023 12:30:09 +0200 Subject: [PATCH] r/consensus: expose learner start offset from consensus Signed-off-by: Michal Maslanka --- src/v/raft/consensus.cc | 9 +++++++++ src/v/raft/consensus.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/v/raft/consensus.cc b/src/v/raft/consensus.cc index c1a197b6ef021..ed8082bfdad6f 100644 --- a/src/v/raft/consensus.cc +++ b/src/v/raft/consensus.cc @@ -3846,4 +3846,13 @@ void consensus::upsert_recovery_state( } } +std::optional consensus::get_learner_start_offset() const { + const auto& latest_cfg = _configuration_manager.get_latest(); + + if (latest_cfg.get_configuration_update()) { + return latest_cfg.get_configuration_update()->learner_start_offset; + } + return std::nullopt; +} + } // namespace raft diff --git a/src/v/raft/consensus.h b/src/v/raft/consensus.h index 5b7b9fffde981..ec073ebb5d93b 100644 --- a/src/v/raft/consensus.h +++ b/src/v/raft/consensus.h @@ -752,6 +752,8 @@ class consensus { model::offset leader_last_offset, bool already_recovering); + std::optional get_learner_start_offset() const; + bool use_serde_configuration() const { return _features.is_active(features::feature::raft_config_serde); }