diff --git a/raft/fsm.cc b/raft/fsm.cc index b519a68d2e..3df087734b 100644 --- a/raft/fsm.cc +++ b/raft/fsm.cc @@ -1029,7 +1029,7 @@ bool fsm::apply_snapshot(snapshot_descriptor snp, size_t max_trailing_entries, s // If the snapshot is local, _commit_idx is larger than snp.idx. // Otherwise snp.idx becomes the new commit index. _commit_idx = std::max(_commit_idx, snp.idx); - _output.snp.emplace(fsm_output::applied_snapshot{snp, local}); + _output.snp.emplace(fsm_output::applied_snapshot{snp, local, max_trailing_entries}); size_t units = _log.apply_snapshot(std::move(snp), max_trailing_entries, max_trailing_bytes); if (is_leader()) { logger.trace("apply_snapshot[{}]: signal {} available units", _my_id, units); diff --git a/raft/fsm.hh b/raft/fsm.hh index 84498f7054..a72c5adaae 100644 --- a/raft/fsm.hh +++ b/raft/fsm.hh @@ -21,6 +21,11 @@ struct fsm_output { struct applied_snapshot { snapshot_descriptor snp; bool is_local; + + // Always 0 for non-local snapshots. + size_t max_trailing_entries; + + // FIXME: include max_trailing_bytes here and in store_snapshot_descriptor }; std::optional> term_and_vote; std::vector log_entries; diff --git a/raft/server.cc b/raft/server.cc index 580674d758..cb9be0df70 100644 --- a/raft/server.cc +++ b/raft/server.cc @@ -1003,10 +1003,10 @@ future<> server_impl::io_fiber(index_t last_stable) { } if (batch.snp) { - auto& [snp, is_local] = *batch.snp; + auto& [snp, is_local, max_trailing_entries] = *batch.snp; logger.trace("[{}] io_fiber storing snapshot {}", _id, snp.id); // Persist the snapshot - co_await _persistence->store_snapshot_descriptor(snp, is_local ? _config.snapshot_trailing : 0); + co_await _persistence->store_snapshot_descriptor(snp, max_trailing_entries); _stats.store_snapshot++; // If this is locally generated snapshot there is no need to // load it.