sumitagrawl commented on code in PR #10617:
URL: https://github.com/apache/ozone/pull/10617#discussion_r3556813837
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java:
##########
@@ -278,34 +293,41 @@ public void notifyLeaderChanged(RaftGroupMemberId
groupMemberId,
return;
}
- currentLeaderTerm.set(scm.getScmHAManager().getRatisServer().getDivision()
- .getInfo().getCurrentTerm());
-
- if (isStateMachineReady.compareAndSet(false, true)) {
- // refresh and validate safe mode rules if it can exit safe mode
- // if being leader, all previous term transactions have been applied
- // if other states, just refresh safe mode rules, and transaction keeps
flushing from leader
- // and does not depend on pending transactions.
- scm.getScmSafeModeManager().refreshAndValidate();
- }
-
- if (!groupMemberId.getPeerId().equals(newLeaderId)) {
+ final boolean isLeader = groupMemberId.getPeerId().equals(newLeaderId);
+
+ if (!isLeader) {
+ // Follower: capture the leader's current committed index as the fixed
+ // catch-up target (only while not yet ready), then start the datanode
+ // protocol server if we are already caught up with it; otherwise
+ // applyTransaction / notifyTermIndexUpdated start it as catch-up
completes.
+ if (!isStateMachineReady.get()) {
+ long leaderCommit = getLeaderCommitIndex();
+ if (leaderCommit >= 0) {
Review Comment:
we need not check leaderCommit >= 0 as leader change may bring another
leader and their commit index may be different. so its ok to set always
--
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]