Yes, for one directory configuration, we may use only StartupOption.RECOVER.

FYI, there is a related problem about storage being accidentally
reformatted; https://issues.apache.org/jira/browse/RATIS-1995

Tsz-Wo


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

> I saw "The problem happens only if more than one directories are
> configured. When only one directory is configured, the problem won't
> happen. In the JIRA, we will allow auto format in the single directory
> case." in [1].
>
> So, if I'm sure only one directory is configured, I can always use
> StartupOption.RECOVER. If it's possible to have multiple directories
> configured, perhaps I should write a launcher to check the directories
> and determine which startup option should be used.
>
> Best,
> tison.
>
> [1] https://issues.apache.org/jira/browse/RATIS-1871
>
> Tsz Wo Sze <[email protected]> 于2024年1月10日周三 09:50写道:
> >
> > 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