Repository navigation
[fix][broker] Preserve topic initialization failures - #26775
Merged
nodece merged 1 commit intoSep 30, 2026
Merged
Conversation
PersistentTopic.initialize() loads the namespace policies, then the topic policies, and then removes orphan replication cursors. A failure in any of these stages was logged and ignored, isEncryptionRequired was set to false, and the topic was loaded anyway with settings that did not match its configured policies. Remove the exceptionally handler so these failures fail the initialization. The existing handling in BrokerService then closes the partially initialized topic and removes it from the topic cache, so a later load retries. Its log message now describes this as a topic initialization failure. Add a test that simulates a failure in each stage and verifies that the load fails, the topic is closed and removed from the cache, and a retry applies the configured policies. Correct the topic policies mock in testGetReplicationClusters, which relied on the ignored failure; it now verifies that topic-level replication clusters override namespace-level ones. Assisted-by: Claude Code
lhotari
requested review from
Technoboy-,
dao-jun,
david-streamlio,
merlimat and
nodece
September 30, 2026 00:44
dao-jun
approved these changes
Sep 30, 2026
nodece
approved these changes
Sep 30, 2026
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Oct 1, 2026
(cherry picked from commit c623cfd)
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Oct 2, 2026
(cherry picked from commit c623cfd)
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
PersistentTopic.initialize()loads the namespace policies, then the topic policies, and then removes orphan replication cursors. When any of these stages failed, the failure was logged and ignored,isEncryptionRequiredwas set tofalse, and the topic was loaded anyway. The topic then served clients with settings that did not match its configured policies, and it stayed loaded until it was unloaded.A topic should only become available after its initialization succeeds.
Modifications
exceptionallyhandler inPersistentTopic.initialize(), so a failure in loading namespace policies, loading topic policies or removing orphan replication cursors fails the initialization.BrokerServicethen closes the partially initialized topic and removes it from the topic cache, so a later load retries the initialization. Its log message now describes this as a topic initialization failure.PersistentTopicTest#testGetReplicationClusters(inorg.apache.pulsar.broker.service). The test no longer relies on an ignored initialization failure, and it now verifies that topic-level replication clusters override the namespace-level ones.Verifying this change
This change added tests and can be verified as follows:
PersistentTopicTest#testInitializationFailureClosesTopicAndAllowsRetry(inorg.apache.pulsar.broker.service.persistent), which simulates a failure in loading namespace policies, loading topic policies, or removing an orphan replication cursor. It checks that the topic load fails, the topic is removed from the cache and its managed ledger is closed, and that a retry loads the topic with the configured policies applied.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes