In order to prevent data loss, new servers should be formatted explicitly.
Auto-format may cause data loss as described in
https://issues.apache.org/jira/browse/RATIS-1677 .

Tsz-Wo

On Tue, Jan 9, 2024 at 5:32 PM tison <[email protected]> wrote:

> Thank you! Now I can make things work with
> `.setOption(RaftStorage.StartupOption.RECOVER)` on
> `RaftServer.newBuilder()`.
>
> I noticed that [1] enables fallback to format if recovery fails. And
> it meets my intuition that we can always try to recover and initialize
> if it fails. Still, the initialization can fail with "Failed to
> FORMAT: One or more existing directories found". I wonder when it's
> desired to configure `.setOption(RaftStorage.StartupOption.FORMAT)`
> since [1] is there.
>
> Best,
> tison.
>
> [1] https://github.com/apache/ratis/pull/903
>
> Tsz Wo Sze <[email protected]> 于2024年1月10日周三 08:57写道:
> >
> > > ... between the two starting-ups.
> >
> > It is related to RaftStorage.StartupOption -- the default is FORMAT so
> the first time can successfully start up.  However, it failed to start up
> the second time since the directory was already formatted.  We should use
> the RECOVER option for the subsequent startups.  This change was for
> https://issues.apache.org/jira/browse/RATIS-1677 .
> >
> > Sorry for the inconvenience.
> >
> > Tsz-Wo
> >
> >
> > On Tue, Jan 9, 2024 at 4:40 PM tison <[email protected]> wrote:
> >>
> >> Hi,
> >>
> >> It's a bit unexpected that startup and shutdown a ratis server with an
> >> empty state machine (extends BaseStateMachine without any override)
> >> returns this error:
> >>
> >> > Failed to FORMAT: One or more existing directories found
> >>
> >> The data under the directory should be compatible between the two
> starting-ups.
> >>
> >> You can reproduce it with [1] running EtcdServer's main function twice.
> >>
> >> I don't know why I encountered this exception and if it's a bug or if
> >> I should modify the application logic.
> >>
> >> Best,
> >> tison.
> >>
> >> [1] https://github.com/tisonkun/ratis-etcd
>

Reply via email to