errose28 commented on code in PR #12218:
URL: https://github.com/apache/ozone/pull/12218#discussion_r4773743366
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java:
##########
@@ -353,46 +355,38 @@ public void notifyLeaderChanged(RaftGroupMemberId
groupMemberId,
}
final boolean isLeader = groupMemberId.getPeerId().equals(newLeaderId);
-
- if (!isLeader) {
- // Follower: capture the (possibly new) leader's current committed index
- // as the fixed catch-up target, then start the datanode protocol server
- // if we are already caught up with it; otherwise applyTransaction /
- // notifyTermIndexUpdated start it as catch-up completes. Set it always:
- // getLeaderCommitIndex() returns -1 when the leader is not known yet,
- // which isFollowerCaughtUp() treats as uncaptured and re-reads later.
+ final String message;
+
+ if (isLeader) {
+ long currentTerm =
scm.getScmHAManager().getRatisServer().getDivision().getInfo().getCurrentTerm();
+ message = "current SCM " + scm.getScmId() + " becomes leader of term " +
currentTerm;
+
+ scm.getScmContext().updateLeaderAndTerm(true, currentTerm);
+ scm.getSequenceIdGen().invalidateBatch();
+
+ DeletedBlockLog deletedBlockLog =
scm.getScmBlockManager().getDeletedBlockLog();
+ Preconditions.checkArgument(deletedBlockLog instanceof
DeletedBlockLogImpl);
+ ((DeletedBlockLogImpl) deletedBlockLog).onBecomeLeader();
+ scm.getScmDecommissionManager().onBecomeLeader();
Review Comment:
I kept master's order in the latest commit, but added distinct blocks for
leader and follower scenarios since the early return formatting of the original
method contributed to the bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]