You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "mjsax (via GitHub)" <gi...@apache.org> on 2025/05/02 03:45:55 UTC

[PR] MINOR: improve AdjustStreamThreadCountTest [kafka]

mjsax opened a new pull request, #19617:
URL: https://github.com/apache/kafka/pull/19617

   The test is failing once in a while but there is not enough information in the logs to determine the root cause. Adding more information, and fixing thread resource leak.


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: improve AdjustStreamThreadCountTest [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax merged PR #19617:
URL: https://github.com/apache/kafka/pull/19617


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: improve AdjustStreamThreadCountTest [kafka]

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru commented on code in PR #19617:
URL: https://github.com/apache/kafka/pull/19617#discussion_r2072902337


##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java:
##########
@@ -239,10 +241,30 @@ public void shouldAddAndRemoveThreadsMultipleTimes() throws InterruptedException
             final CountDownLatch latch = new CountDownLatch(2);
             final Thread one = adjustCountHelperThread(kafkaStreams, 4, latch);
             final Thread two = adjustCountHelperThread(kafkaStreams, 6, latch);
-            two.start();
-            one.start();
-            latch.await(30, TimeUnit.SECONDS);
-            assertThat(kafkaStreams.metadataForLocalThreads().size(), equalTo(oldThreadCount));
+            Set<ThreadMetadata> threadMetadata = null;
+
+            AssertionError testError = null;
+            try {
+                two.start();
+                one.start();
+
+                assertTrue(latch.await(30, TimeUnit.SECONDS));
+                one.join();

Review Comment:
   I would have just expected the `join`s to be after the assertion, if you want to fix just a thread leak problem and preserve the test otherwise. still, LGTM



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: improve AdjustStreamThreadCountTest [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #19617:
URL: https://github.com/apache/kafka/pull/19617#discussion_r2071933067


##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java:
##########
@@ -239,10 +241,30 @@ public void shouldAddAndRemoveThreadsMultipleTimes() throws InterruptedException
             final CountDownLatch latch = new CountDownLatch(2);
             final Thread one = adjustCountHelperThread(kafkaStreams, 4, latch);
             final Thread two = adjustCountHelperThread(kafkaStreams, 6, latch);
-            two.start();
-            one.start();
-            latch.await(30, TimeUnit.SECONDS);
-            assertThat(kafkaStreams.metadataForLocalThreads().size(), equalTo(oldThreadCount));
+            Set<ThreadMetadata> threadMetadata = null;
+
+            AssertionError testError = null;
+            try {
+                two.start();
+                one.start();
+
+                assertTrue(latch.await(30, TimeUnit.SECONDS));
+                one.join();

Review Comment:
   > and fixing thread resource leak.
   
   Don't think the `join()` order matters? But before, we did not join the threads at all?
   
   Each thread count down the latch right before it exits, and we wait for the latch above.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: improve AdjustStreamThreadCountTest [kafka]

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru commented on code in PR #19617:
URL: https://github.com/apache/kafka/pull/19617#discussion_r2071176921


##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java:
##########
@@ -239,10 +241,30 @@ public void shouldAddAndRemoveThreadsMultipleTimes() throws InterruptedException
             final CountDownLatch latch = new CountDownLatch(2);
             final Thread one = adjustCountHelperThread(kafkaStreams, 4, latch);
             final Thread two = adjustCountHelperThread(kafkaStreams, 6, latch);
-            two.start();
-            one.start();
-            latch.await(30, TimeUnit.SECONDS);
-            assertThat(kafkaStreams.metadataForLocalThreads().size(), equalTo(oldThreadCount));
+            Set<ThreadMetadata> threadMetadata = null;
+
+            AssertionError testError = null;
+            try {
+                two.start();
+                one.start();
+
+                assertTrue(latch.await(30, TimeUnit.SECONDS));
+                one.join();

Review Comment:
   Doesn't this change the test, since you are joining `one` and `two` before asserting? Not strictly against that, just pointing it out because the PR description only mentions collecting extra logs and fixing a thread leak.



-- 
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-unsubscribe@kafka.apache.org

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