BewareMyPower commented on PR #25707:
URL: https://github.com/apache/pulsar/pull/25707#issuecomment-4477511199
I tried to write a test to reproduce and then found that even if a listener
is registered due to the race, there still might be a real issue.
```java
private static final CountDownLatch realCloseLatch = new
CountDownLatch(1);
private static final CountDownLatch closeLatch = new CountDownLatch(1);
public static class MockTopicPoliciesService extends
MetadataStoreTopicPoliciesService {
public void close() {
super.close();
realCloseLatch.countDown();
try {
if (!closeLatch.await(10, TimeUnit.SECONDS)) {
log.info().log("Failed to close TopicPoliciesService
within the timeout");
}
} catch (InterruptedException e) {
log.info().log("Interrupted when closing
TopicPoliciesService");
}
}
}
```
The test can be easily written based on the mocked implementation above.
`MetadataStoreTopicPoliciesService#close` is a very simple operation that
changes `closed` to `true`. Even if a different broker receives a topic
policies update request and updates the policies, `handleNotification` will
skip calling `notifyListeners` in
https://github.com/apache/pulsar/blob/8652efa4d60b791a5f1ee4e52f7ffda6ebbbb256/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/MetadataStoreTopicPoliciesService.java#L195-L200
Therefore, basically these zombie listeners won't be notified.
In another case, if the CAS of the `closed` flag happened before listeners
were notified, where asynchronous operations had been started, these listeners
would be cleared and would not be notified anymore.
--
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]