sofastack/sofa-jraft

When deploying a PD single node, there is a probability that onLeaderStart cannot be called.

ye-xiaowei opened this issue · 2 comments

Describe the bug

Because the store was initialized first, followed by the call to addLeaderStateListerer. Perhaps onLeaderStart has already been called.
Can I adjust the code order in PlacementDriverServer # init?

this.rheaKVStore = new DefaultRheaKVStore();
this.placementDriverService = new DefaultPlacementDriverService(this.rheaKVStore);
this.rheaKVStore.addLeaderStateListener(-1, ((DefaultPlacementDriverService) this.placementDriverService));
if (!this.rheaKVStore.init(rheaOpts)) {
    LOG.error("Fail to init [RheaKVStore].");
    return false;
}

Looks good, can you create a PR to fix it?

Looks good, can you create a PR to fix it?

Sure