ableegoldman commented on a change in pull request #11857:
URL: https://github.com/apache/kafka/pull/11857#discussion_r820598589



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/TopologyMetadata.java
##########
@@ -161,35 +161,47 @@ public void registerThread(final String threadName) {
 
     public void unregisterThread(final String threadName) {
         threadVersions.remove(threadName);
-        
maybeNotifyTopologyVersionWaitersAndUpdateThreadsTopologyVersion(threadName);
+        maybeNotifyTopologyVersionListeners();
     }
 
     public TaskExecutionMetadata taskExecutionMetadata() {
         return taskExecutionMetadata;
     }
 
-    public void 
maybeNotifyTopologyVersionWaitersAndUpdateThreadsTopologyVersion(final String 
threadName) {
+    public Set<String> updateThreadTopologyVersion(final String threadName) {
         try {
-            lock();
-            final Iterator<TopologyVersionWaiters> iterator = 
version.activeTopologyWaiters.listIterator();
-            TopologyVersionWaiters topologyVersionWaiters;
+            version.topologyLock.lock();
             threadVersions.put(threadName, topologyVersion());

Review comment:
       @wcarlson5 / @guozhangwang  / @vvcephei  This is the main fix -- we need 
to split out the version update where we add the current thread with the latest 
topology version to this `threadVersions` map, since this of course should only 
be done when we're reacting to a topology update.
   
   The other function of the method was to check whether we could complete any 
of the queued listeners, which is why we were invoking this when shutting down 
a thread. Splitting this out into a separate method avoids ghost threads being 
left behind in the `threadVersions` map




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