[fix][broker] Skip backlog-quota eviction on fenced/closing topics#25684
Open
lhotari wants to merge 1 commit intoapache:masterfrom
Open
[fix][broker] Skip backlog-quota eviction on fenced/closing topics#25684lhotari wants to merge 1 commit intoapache:masterfrom
lhotari wants to merge 1 commit intoapache:masterfrom
Conversation
`BrokerService.monitorBacklogQuota` runs every `backlogQuotaCheckIntervalInSeconds` (default 60s, but reduced to 2s in some tests) and iterates every persistent topic on the broker. For each topic it calls `BacklogQuotaManager.handleExceededBacklogQuota`, which ultimately mutates managed-ledger cursor state via `slowestConsumer.skipEntries` and `markDeletePositionMoveForward`. Today this runs unconditionally, even on topics that have already been fenced (transient interceptor exception) or are being torn down (`isClosingOrDeleting`). When a namespace is being force-deleted under quota pressure, the checker contends with the delete path on the same managed ledger / cursor — slowing the deletion and causing intermittent `Awaitility.deleteNamespace` timeouts in tests like `BacklogQuotaManagerTest`. Fix: early-return at the top of `handleExceededBacklogQuota` if the topic reports `isFenced()` or `isClosingOrDeleting()`. The entries are about to be discarded by the close/delete path — running eviction is both wasted work and a source of contention. `isFenced` is auto-generated by Lombok `@Getter` on `AbstractTopic.isFenced`; `isClosingOrDeleting` is auto-generated on `PersistentTopic.isClosingOrDeleting`. No new accessors needed.
2 tasks
merlimat
approved these changes
May 5, 2026
dao-jun
approved these changes
May 6, 2026
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.monitorBacklogQuotaruns everybacklogQuotaCheckIntervalInSecondsand iterates every persistent topic on the broker viaforEachPersistentTopic(BrokerService.java:2476). For each topic it callsBacklogQuotaManager.handleExceededBacklogQuota, which mutates managed-ledger cursor state viaslowestConsumer.skipEntriesandmarkDeletePositionMoveForward(see BacklogQuotaManager.java:140-213).Today this runs unconditionally — including on topics that have already been fenced (e.g. transient ledger-interceptor exception) or are closing/deleting (
fenceTopicToCloseOrDelete()setsisClosingOrDeleting = trueandisFenced = true).When a namespace is being force-deleted under quota pressure, the checker concurrently mutates cursor state on a topic the delete path is trying to tear down. The two compete for the same managed-ledger / cursor, slowing the deletion. This was observed as intermittent
Awaitility.deleteNamespacetimeouts inBacklogQuotaManagerTest— see https://github.com/apache/pulsar/actions/runs/25387367872/job/74455105884 (PR #25676 attempt 1).A test-side workaround for the symptom is in #25680; this PR addresses the underlying broker behavior.
Modifications
Early-return at the top of
BacklogQuotaManager.handleExceededBacklogQuotaif the topic reportsisFenced()orisClosingOrDeleting():Both methods are auto-generated by Lombok
@Getteron the existing fields (AbstractTopic.isFenced,PersistentTopic.isClosingOrDeleting). No new accessors needed.Verifying this change
This change is already covered by existing tests, such as
BacklogQuotaManagerTest.testConsumerBacklogEvictionSizeQuotaCleansPendingAcksandBacklogQuotaManagerTest.testConsumerBacklogEvictionTimeQuotaNotPreciseCleansPendingAcks(the normal-path eviction is exercised; both pass locally with this change applied).The skipped path (fenced/closing topic) is a correctness no-op: the entries to be evicted are about to be discarded anyway by the close/delete pipeline, so the only observable effect is the absence of redundant cursor mutations during teardown.
Does this pull request potentially affect one of the following parts: