lni / dragonboat

A feature complete and high performance multi-group Raft library in Go.
Apache License 2.0
4.98k stars 533 forks source link

how to know the shard is ready #266

Closed ZSJGG closed 1 year ago

ZSJGG commented 1 year ago

Note: for reported bugs, please fill in the following details. bug reports without detailed steps on how to reproduce will be automatically closed.

Dragonboat version

v4.0.0

Expected behavior

Follow the StartReplica(), call the SyncPropose() to update the instance of IStatementMachine

Actual behavior

After StartReplica(), SyncPropose()will return shard is not ready

Steps to reproduce the behavior

kevburnsjr commented 1 year ago

I imagine you could just write a loop that attempts to read index and report the shard as ready when the read succeeds. No?

lni commented 1 year ago

With 4.0 being an API breaking upgrade, I actually looked into the StartReplica API, I thought it might be a good idea to allow users to specify an extra flag indicating that they want StartReplica to return only after the replica is ready to be used. But I quickly realized that it won't help much - such new API can make sure that the replica is always in a ready state on StartReplica's return, but then the replica's status can change from ready to not ready at any time when the leader becomes unknown for whatever reason. In the end, users still face the exact same situation - the replica is possible to be in a not ready state.

In short, we all need to accept it as a normal part of life in distributed systems that your nodes can get into such "not ready" state and different applications can react to that in completely different ways, some of them might choose to give up and try again in a few seconds, some might want to keep retrying until timeout.

ZSJGG commented 1 year ago

@lni @kevburnsjr Thank you for your reply all, I got it.