[fix][broker] Prevent stale topic unload cleanup from removing active cache entries - #26145
Merged
lhotari merged 2 commits intoJul 25, 2026
Merged
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.
void-ptr974
force-pushed
the
fix/broker-service-unload-cache-cleanup
branch
from
July 4, 2026 04:35
d363eb1 to
1c9beb8
Compare
Denovo1998
suggested changes
Jul 12, 2026
Denovo1998
approved these changes
Jul 13, 2026
lhotari
approved these changes
Jul 25, 2026
sandeep-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 31, 2026
… cache entries (apache#26145) (cherry picked from commit 73549d2)
sandeep-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 31, 2026
… cache entries (apache#26145) (cherry picked from commit 73549d2)
sandeep-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 31, 2026
… cache entries (apache#26145) (cherry picked from commit 73549d2)
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Aug 28, 2026
… cache entries (apache#26145) (cherry picked from commit 73549d2) Signed-off-by: Zixuan Liu <nodeces@gmail.com>
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