frankvicky commented on code in PR #24121:
URL: https://github.com/apache/kafka/pull/24121#discussion_r4553547227


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/InternalTopicManagerTest.java:
##########
@@ -162,7 +164,64 @@ public void 
shouldBackOffBetweenRoundsWhenTopicIsMarkedForDeletion() {
             TimeoutException.class,
             () -> 
internalTopicManager.makeReady(Collections.singletonMap(topic1, 
internalTopicConfig))
         );
-        assertEquals(50L, time.milliseconds() - before);
+
+        // The timeout is 50 ms and retry.backoff.ms is 10 ms. The backoff 
doubles each round
+        // (10, 20, 40 ms), each with +/- jitter. The deadline is only checked 
before a sleep,
+        // so exactly three sleeps happen: after two sleeps the clock is at 
most 36 ms (< 50),
+        // and after three it is at least 56 ms (>= 50).
+        final long elapsed = time.milliseconds() - before;
+        long minElapsed = 0;
+        long maxElapsed = 0;
+        for (int round = 0; round < 3; round++) {
+            minElapsed += backoffBoundMs(10, round, 1 - 
CommonClientConfigs.RETRY_BACKOFF_JITTER);
+            maxElapsed += backoffBoundMs(10, round, 1 + 
CommonClientConfigs.RETRY_BACKOFF_JITTER);
+        }
+        assertTrue(elapsed >= minElapsed && elapsed <= maxElapsed,
+            "Elapsed time " + elapsed + " is outside [" + minElapsed + ", " + 
maxElapsed + "]");
+    }
+
+    @Test
+    @Timeout(30)
+    public void 
shouldIncreaseBackOffBetweenRoundsWhenTopicIsMarkedForDeletion() {
+        mockAdminClient.addTopic(

Review Comment:
   nit: 
   only `makeReady` is covered. Could we add a similar test for 
`getTopicPartitionInfo`? 
   It does not go through `maybeSleep`, so nothing checks its backoff growth 
today.



##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:
##########
@@ -93,7 +95,15 @@ public InternalTopicManager(final Time time,
 
         replicationFactor = 
streamsConfig.getInt(StreamsConfig.REPLICATION_FACTOR_CONFIG).shortValue();
         windowChangeLogAdditionalRetention = 
streamsConfig.getLong(StreamsConfig.WINDOW_STORE_CHANGE_LOG_ADDITIONAL_RETENTION_MS_CONFIG);
-        retryBackOffMs = 
streamsConfig.getLong(StreamsConfig.RETRY_BACKOFF_MS_CONFIG);
+        final long retryBackoffMs = 
streamsConfig.getLong(StreamsConfig.RETRY_BACKOFF_MS_CONFIG);
+        // Streams has no retry.backoff.max.ms config, so use the client 
default as the cap,
+        // but never cap below the configured initial backoff.
+        retryBackoff = new ExponentialBackoff(

Review Comment:
   this is a user visible change in retry timing. 
   Should we add a line to the Streams upgrade guide?
   cc @mjsax 



##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/InternalTopicManagerTest.java:
##########
@@ -162,7 +164,64 @@ public void 
shouldBackOffBetweenRoundsWhenTopicIsMarkedForDeletion() {
             TimeoutException.class,
             () -> 
internalTopicManager.makeReady(Collections.singletonMap(topic1, 
internalTopicConfig))
         );
-        assertEquals(50L, time.milliseconds() - before);
+
+        // The timeout is 50 ms and retry.backoff.ms is 10 ms. The backoff 
doubles each round
+        // (10, 20, 40 ms), each with +/- jitter. The deadline is only checked 
before a sleep,
+        // so exactly three sleeps happen: after two sleeps the clock is at 
most 36 ms (< 50),
+        // and after three it is at least 56 ms (>= 50).
+        final long elapsed = time.milliseconds() - before;

Review Comment:
   nit: `shouldIncreaseBackOffBetweenRoundsWhenTopicIsMarkedForDeletion` below 
checks every sleep against its bounds, which already implies this total. Could 
we merge the two tests?



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

Reply via email to