[Summer of code] Let controller become role state after append initial logs (#4442)

* fix bug

* fix bug
This commit is contained in:
hzh0425
2022-06-10 13:59:37 +08:00
committed by GitHub
parent 81dc9386a1
commit 6645d0a42b
2 changed files with 2 additions and 2 deletions
@@ -403,7 +403,6 @@ public class DLedgerController implements Controller {
DLedgerController.this.stopScheduling();
break;
case LEADER: {
this.currentRole = MemberState.Role.LEADER;
log.info("Controller {} change role to leader, try process a initial proposal", this.selfId);
// Because the role becomes to leader, but the memory statemachine of the controller is still in the old point,
// some committed logs have not been applied. Therefore, we must first process an empty request to dledger,
@@ -414,6 +413,7 @@ public class DLedgerController implements Controller {
request.setBody(new byte[0]);
try {
if (appendToDledgerAndWait(request)) {
this.currentRole = MemberState.Role.LEADER;
DLedgerController.this.startScheduling();
break;
}
@@ -54,8 +54,8 @@ public class DLedgerControllerStateMachine implements StateMachine {
if (body != null && body.length > 0) {
final EventMessage event = this.eventSerializer.deserialize(body);
this.replicasInfoManager.applyEvent(event);
applyingSize++;
}
applyingSize++;
}
log.info("Apply {} events on controller {}", applyingSize, this.dledgerId);
}