vamossagar12 commented on code in PR #13453:
URL: https://github.com/apache/kafka/pull/13453#discussion_r1151411130


##########
connect/runtime/src/test/java/org/apache/kafka/connect/storage/KafkaStatusBackingStoreTest.java:
##########
@@ -308,6 +308,37 @@ public void readTaskState() {
         assertEquals(status, store.get(TASK));
     }
 
+    @Test
+    public void readTaskStateShouldIgnoreStaleStatuses() {
+        byte[] value = new byte[0];
+        String otherWorkerId = "anotherhost:8083";
+
+        // This worker sends a RUNNING status in the most recent generation
+        Map<String, Object> firstStatusRead = new HashMap<>();
+        firstStatusRead.put("worker_id", otherWorkerId);
+        firstStatusRead.put("state", "RUNNING");
+        firstStatusRead.put("generation", 10L);
+
+        // Another worker still ends up producing an UNASSIGNED status before 
it could
+        // read the newer RUNNING status from above belonging to an older 
generation.
+        Map<String, Object> secondStatusRead = new HashMap<>();
+        secondStatusRead.put("worker_id", WORKER_ID);
+        secondStatusRead.put("state", "UNASSIGNED");
+        secondStatusRead.put("generation", 9L);
+
+        when(converter.toConnectData(STATUS_TOPIC, value))
+                .thenReturn(new SchemaAndValue(null, firstStatusRead))
+                .thenReturn(new SchemaAndValue(null, secondStatusRead));
+
+        store.read(consumerRecord(0, "status-task-conn-0", value));
+        store.read(consumerRecord(0, "status-task-conn-0", value));
+
+        verify(kafkaBasedLog, never()).send(anyString(), any(), 
any(Callback.class));

Review Comment:
   Oh I see. This came by due to a direct copy-paste :) Will remove it. Thanks 
for pointing it out!



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