[fix][broker] Prevent stale topic unload cleanup from removing active cache entries#26145
Open
void-ptr974 wants to merge 1 commit into
Open
[fix][broker] Prevent stale topic unload cleanup from removing active cache entries#26145void-ptr974 wants to merge 1 commit into
void-ptr974 wants to merge 1 commit into
Conversation
cleanUnloadedTopicFromCache is a best-effort cleanup after bundle unload. It previously removed topics by name and could remove a newer topic future installed after a stale unload cleanup started. Only clean fenced topics and remove cache entries using the captured topic future. Skip unload side effects when the cache entry was already removed or superseded. Add tests for stale cleanup preserving a newer topic future and cleanup of inactive fenced topic futures.
d363eb1 to
1c9beb8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
BrokerService.topicsentries can be replaced when a topic is loaded again after a bundle unload or topic close path has started.Before this change,
cleanUnloadedTopicFromCachecould remove a topic by name only, andremoveTopicFromCachecould still dispatch unload side effects after the matching cache entry had already been replaced. A stale cleanup callback could remove a newer active topic future or clear auxiliary broker-local state for a superseded entry.Modifications
cleanUnloadedTopicFromCacheclean only topics already fenced by close/unload.BrokerService.topicswith the captured topic future when one is available.Verifying this change
./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.BrokerServiceTest.testCleanUnloadedTopicFromCacheDoesNotRemoveNewTopicFuture --tests org.apache.pulsar.broker.service.BrokerServiceTest.testRemoveTopicFromCacheDoesNotRemoveSupersededTopicFuture --tests org.apache.pulsar.broker.service.BrokerServiceTest.testCleanUnloadedTopicFromCacheRemovesInactiveBundleTopicFuture./gradlew :pulsar-broker:checkstyleMain :pulsar-broker:checkstyleTestgit diff --check