You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/01/14 22:34:01 UTC

[GitHub] [kafka] wcarlson5 commented on a change in pull request #9887: KAFKA-12195 Fix synchronization issue happening in KafkaStreams

wcarlson5 commented on a change in pull request #9887:
URL: https://github.com/apache/kafka/pull/9887#discussion_r557739729



##########
File path: streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
##########
@@ -989,16 +989,20 @@ private StreamThread createAndAddStreamThread(final long cacheSizePerThread, fin
     public Optional<String> removeStreamThread() {
         if (isRunningOrRebalancing()) {
             synchronized (changeThreadCount) {
-                for (final StreamThread streamThread : threads) {
-                    if (streamThread.isAlive() && (!streamThread.getName().equals(Thread.currentThread().getName()) || threads.size() == 1)) {
-                        streamThread.shutdown();
-                        if (!streamThread.getName().equals(Thread.currentThread().getName())) {
-                            streamThread.waitOnThreadState(StreamThread.State.DEAD);
+                synchronized (threads) {

Review comment:
       Why are we using the threads object as a lock here? is that was the `Collections.synchronizedList(new LinkedList<>());` uses internally?
   
   I am a little concerned that we are holding `changeThreadCount` while waiting for `threads`




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

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