lni / dragonboat

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

How to delete all replicas of a specific shard? #364

Closed luluz66 closed 3 months ago

luluz66 commented 4 months ago

In dragonboat, I can use nodehost.SyncRequestDeleteReplica to delete a replica of a specific shard. But it doesn't let me to delete the last replica of the shard. (code)

How can I delete a shard completely, in particular, remove all replicas of this shard?

lni commented 3 months ago

I don't think you can remove all replicas of a shard, as a shard with 0 replica is not considered as valid in dragonboat.

To remove a shard completely, including all associated data of the shard, you can just stop all replicas and use the RemoveData() method on all involved machines to delete all associated data. Note that you are not suppose to restart those replicas once their data is removed.