You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Jie Yao (Jira)" <ji...@apache.org> on 2022/03/07 07:55:00 UTC
[jira] [Updated] (RATIS-1548) use stateMachine#lastAppliedIndex instead of stateMachinUpdater#lastAppliedIndex when check snapshot should be taken
[ https://issues.apache.org/jira/browse/RATIS-1548?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jie Yao updated RATIS-1548:
---------------------------
Description:
for now, the following is used to check whether a snapshot should be taken
{code:java}
return state == State.RUNNING && getLastAppliedIndex() - snapshotIndex.get() >= autoSnapshotThreshold; {code}
but `getLastAppliedIndex` is the index recorded by stateMachineUpdater, not state machine itself. in some other case (for example, om), the lastAppliedIndex of state machine will not be updated immediately after `applyTransaction` is called . in om , lastAppliedIndex will be updated until the ready queue of double buffer is flushed.
so here `stateMachineUpdater#getLastAppliedIndex()` does not always equal to `stateMachine#lastAppliedIndex`
was:
for now, the following is used to check whether a snapshot should be taken
{code:java}
return state == State.RUNNING && getLastAppliedIndex() - snapshotIndex.get() >= autoSnapshotThreshold; {code}
but `getLastAppliedIndex` is the index recorded by stateMachineUpdater, not state machine itself. in some other case (for example, om), the lastAppliedIndex of state machine will not be updated immediately after `applyTransaction` is called . in om , lastAppliedIndex will be updated until the ready queue of double buffer is flushed.
> use stateMachine#lastAppliedIndex instead of stateMachinUpdater#lastAppliedIndex when check snapshot should be taken
> --------------------------------------------------------------------------------------------------------------------
>
> Key: RATIS-1548
> URL: https://issues.apache.org/jira/browse/RATIS-1548
> Project: Ratis
> Issue Type: Bug
> Reporter: Jie Yao
> Assignee: Jie Yao
> Priority: Major
>
> for now, the following is used to check whether a snapshot should be taken
> {code:java}
> return state == State.RUNNING && getLastAppliedIndex() - snapshotIndex.get() >= autoSnapshotThreshold; {code}
> but `getLastAppliedIndex` is the index recorded by stateMachineUpdater, not state machine itself. in some other case (for example, om), the lastAppliedIndex of state machine will not be updated immediately after `applyTransaction` is called . in om , lastAppliedIndex will be updated until the ready queue of double buffer is flushed.
> so here `stateMachineUpdater#getLastAppliedIndex()` does not always equal to `stateMachine#lastAppliedIndex`
--
This message was sent by Atlassian Jira
(v8.20.1#820001)