mirror of
https://github.com/apache/rocketmq.git
synced 2026-09-01 15:47:01 +08:00
[Summer of code] Let controller become role state after append initial logs (#4442)
* fix bug * fix bug
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user