ahuang98 commented on code in PR #16079:
URL: https://github.com/apache/kafka/pull/16079#discussion_r1626317294


##########
raft/src/main/java/org/apache/kafka/raft/LeaderState.java:
##########
@@ -435,16 +438,40 @@ private DescribeQuorumResponseData.ReplicaState 
describeReplicaState(
 
     }
 
+    /**
+     * Clear observer states that have not been active for a while and are not 
the leader.
+     */
     private void clearInactiveObservers(final long currentTimeMs) {
         observerStates.entrySet().removeIf(integerReplicaStateEntry ->
-            currentTimeMs - 
integerReplicaStateEntry.getValue().lastFetchTimestamp >= 
OBSERVER_SESSION_TIMEOUT_MS
+            currentTimeMs - 
integerReplicaStateEntry.getValue().lastFetchTimestamp >= 
OBSERVER_SESSION_TIMEOUT_MS &&
+                integerReplicaStateEntry.getKey() != localId
         );
     }
 
     private boolean isVoter(int remoteNodeId) {
         return voterStates.containsKey(remoteNodeId);
     }
 
+    private void updateVoterAndObserverStates(Set<Integer> lastVoterSet) {

Review Comment:
   I think we can test this indirectly with making sure observers cannot 
influence HW (e.g. if we have two voters, two observers, all observers being 
up-to-date with leader will _not_ cause HW to increase) until they are added 
back to the voterSet. This ensures nodes are correctly removed/added from the 
sets



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to