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


##########
raft/src/test/java/org/apache/kafka/raft/LeaderStateTest.java:
##########
@@ -272,20 +280,109 @@ public void testUpdateHighWatermarkQuorumSizeThree() {
         assertEquals(Optional.empty(), state.highWatermark());
         assertTrue(state.updateReplicaState(node2, 0, new 
LogOffsetMetadata(15L)));
         assertEquals(Optional.of(new LogOffsetMetadata(15L)), 
state.highWatermark());
-        assertFalse(state.updateLocalState(new LogOffsetMetadata(20L)));
+        assertFalse(state.updateLocalState(new LogOffsetMetadata(20L), 
voterSet));
         assertEquals(Optional.of(new LogOffsetMetadata(15L)), 
state.highWatermark());
         assertTrue(state.updateReplicaState(node1, 0, new 
LogOffsetMetadata(20L)));
         assertEquals(Optional.of(new LogOffsetMetadata(20L)), 
state.highWatermark());
         assertFalse(state.updateReplicaState(node2, 0, new 
LogOffsetMetadata(20L)));
         assertEquals(Optional.of(new LogOffsetMetadata(20L)), 
state.highWatermark());
     }
 
+    @Test
+    public void testUpdateHighWatermarkAddingFollowerToVoterStates() {
+        int node1 = 1;
+        int node2 = 2;
+        Set<Integer> originalVoterSet = mkSet(localId, node1);
+        LeaderState<?> state = newLeaderState(originalVoterSet, 10L);
+        assertFalse(state.updateLocalState(new LogOffsetMetadata(15L), 
originalVoterSet));
+        assertFalse(state.updateReplicaState(node1, 0, new 
LogOffsetMetadata(10L)));
+        assertEquals(Optional.empty(), state.highWatermark());
+
+        // updating replica state of 2 before it joins voterSet should not 
increase HW to 15L
+        assertFalse(state.updateReplicaState(node2, 0, new 
LogOffsetMetadata(15L)));
+        assertEquals(Optional.empty(), state.highWatermark());

Review Comment:
   this is for node2 _before_ its in the voter set - so it shouldn't change the 
HW.
   the HW is originally `Optional.empty()` because the voters have end offsets 
equal to the epoch start offset



-- 
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