Skip to content

Commit

Permalink
translation_stm: reset highest translated offset on raft snapshot
Browse files Browse the repository at this point in the history
When an stm receives Raft snapshot it indicates the whole in memory
state of that state machine should be replaced with the state from the
snapshot. The datalake translation state machine was incorrectly
handling raft snapshot which lead to its state being out of date after
the snapshot is applied. Raft snapshot for translation_stm is empty so
the correct action is to reset the state machine state and wait for the
update to be applied.

Fixes: CORE-8485

Signed-off-by: Michał Maślanka <[email protected]>
  • Loading branch information
mmaslankaprv committed Dec 11, 2024
1 parent f454ef2 commit 8985f57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/v/datalake/translation/state_machine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,14 @@ translation_stm::take_local_snapshot(ssx::semaphore_units apply_units) {
co_return raft::stm_snapshot::create(0, snapshot_offset, std::move(result));
}

ss::future<> translation_stm::apply_raft_snapshot(const iobuf&) { co_return; }
ss::future<> translation_stm::apply_raft_snapshot(const iobuf&) {
// reset offset to not initalized when handling Raft snapshot, this way
// state machine will not hold any obsolete state that should be overriden
// with the snapshot.
vlog(_log.debug, "Applying raft snapshot, resetting state");
_highest_translated_offset = kafka::offset{};
co_return;
}

ss::future<iobuf> translation_stm::take_snapshot(model::offset) {
co_return iobuf{};
Expand Down

0 comments on commit 8985f57

Please sign in to comment.