You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ratis.apache.org by tison <wa...@gmail.com> on 2022/10/06 11:58:15 UTC

Shall SimpleStateMachineStorage#getLatestSnapshot call loadLatestSnapshot?

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.

Re: Shall SimpleStateMachineStorage#getLatestSnapshot call loadLatestSnapshot?

Posted by tison <wa...@gmail.com>.
Thank you! I missed the last email >_<

Best,
tison.


Tsz Wo Sze <sz...@gmail.com> 于2022年10月10日周一 18:46写道:

> Filed https://issues.apache.org/jira/browse/RATIS-1723
> Tsz-Wo
>
> On Thu, Oct 6, 2022 at 11:27 PM Tsz Wo Sze <sz...@gmail.com> 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 <wa...@gmail.com> 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.
>>>
>>

Re: Shall SimpleStateMachineStorage#getLatestSnapshot call loadLatestSnapshot?

Posted by Tsz Wo Sze <sz...@gmail.com>.
Filed https://issues.apache.org/jira/browse/RATIS-1723
Tsz-Wo

On Thu, Oct 6, 2022 at 11:27 PM Tsz Wo Sze <sz...@gmail.com> 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 <wa...@gmail.com> 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.
>>
>

Re: Shall SimpleStateMachineStorage#getLatestSnapshot call loadLatestSnapshot?

Posted by Tsz Wo Sze <sz...@gmail.com>.
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 <wa...@gmail.com> 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.
>