Filed https://issues.apache.org/jira/browse/RATIS-1723 Tsz-Wo
On Thu, Oct 6, 2022 at 11:27 PM Tsz Wo Sze <[email protected]> wrote: > Hi tison, > > It looks like a bug -- CounterStateMachine.reinitialize() should use > findLatestSnapshot(), > i.e. > > +++ > b/ratis-examples/src/main/java/org/apache/ratis/examples/counter/server/CounterStateMachine.java > @@ -113,7 +113,7 @@ public class CounterStateMachine extends > BaseStateMachine { > */ > @Override > public void reinitialize() throws IOException { > - load(storage.getLatestSnapshot()); > + load(storage.findLatestSnapshot()); > } > > Tsz-Wo > > > On Thu, Oct 6, 2022 at 7:59 PM tison <[email protected]> wrote: > >> Hi, >> >> Right now, SimpleStateMachineStorage#loadLatestSnapshot only called when >> initialized. Supposed there are several reloads. IIUC, only >> StateMachine#reinitialize will be called. >> >> In CounterStateMachine#reinitialize, it writes: >> >> @Override >> public void reinitialize() throws IOException { >> load(storage.getLatestSnapshot()); >> } >> >> But what if the lastest snapshot changed among multiple reloads? From >> current codebase it seems no one will call loadLatestSnapshot anymore to >> update the field. >> >> Best, >> tison. >> >
