Skip to content

Commit

Permalink
c/archival_stm: translate sync error to not_leader error code
Browse files Browse the repository at this point in the history
When `persisted_stm::sync()` method fails it is indicating that the
current node is not longer a leader. The `sync()` executed before
`replicate` call in archival stm `command_batch_builder` prevents
replicate from being called. The end result for such an error is
deterministic and we can translate the sync error to `not_leader` error
code.

Fixes: redpanda-data#14898

Signed-off-by: Michal Maslanka <michal@redpanda.com>
  • Loading branch information
mmaslankaprv committed Nov 15, 2023
1 parent 2fa7227 commit 4dfdc53
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/v/cluster/archival_metadata_stm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ ss::future<std::error_code> command_batch_builder::replicate() {
auto timeout = now < _deadline ? _deadline - now : 0ms;
return _stm.get().sync(timeout).then([this](bool success) {
if (!success) {
return ss::make_ready_future<std::error_code>(errc::timeout);
return ss::make_ready_future<std::error_code>(errc::not_leader);
}
auto batch = std::move(_builder).build();
return _stm.get().do_replicate_commands(std::move(batch), _as);
Expand Down

0 comments on commit 4dfdc53

Please sign in to comment.