Skip to content

Commit

Permalink
c/log_eviction_stm: do not request snapshot if already progressed
Browse files Browse the repository at this point in the history
It is perfectly possible that the install snapshot request will reach
the follower right before the `log_eviction_stm` asks for the snapshot
creation. In this case an `stm_manager` would do the check and throw an
exception informing that the snapshot can not be taken. In order to
handle the situation gracefully added a check in log eviction stm to
skip taking snapshot if start offset already progressed.

Fixes: redpanda-data#14220

Signed-off-by: Michal Maslanka <michal@redpanda.com>
  • Loading branch information
mmaslankaprv committed Jan 4, 2024
1 parent a870f12 commit 4433851
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/v/cluster/log_eviction_stm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,24 @@ log_eviction_stm::do_write_raft_snapshot(model::offset truncation_point) {
max_collectible_offset,
truncation_point);
}
if (truncation_point <= _raft->last_snapshot_index()) {
vlog(
_log.trace,
"Skipping writing snapshot as Raft already progressed with the new "
"snapshot. Current raft snapshot index: {}, requested truncation "
"point: {}",
_raft->last_snapshot_index(),
truncation_point);
co_return;
}
vlog(
_log.debug,
"Requesting raft snapshot with final offset: {}",
truncation_point);
auto snapshot_data = co_await _raft->stm_manager()->take_snapshot(
truncation_point);

// we need to check snapshot index again as it may already progressed after
// snapshot is taken by stm_manager
if (truncation_point <= _raft->last_snapshot_index()) {
vlog(
_log.trace,
Expand Down

0 comments on commit 4433851

Please sign in to comment.