[fix][broker] Fix early completion and false timeouts in SplitManager and UnloadManager - #26363
Open
void-ptr974 wants to merge 1 commit into
Open
Conversation
…cleanup Assisted-by: Codex
11 tasks
void-ptr974
marked this pull request as ready for review
August 18, 2026 07:30
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
SplitManagerandUnloadManagerkeep one in-flight future per bundle so concurrent callers can wait for the same split or unload operation.The event and close paths completed that future before removing it from the in-flight map. The timeout path attached cleanup with
whenComplete, but discarded the dependent stage and returned the original future. As a result, callers could observe a completed wait while the old entry was still visible. An immediate retry for the same bundle could then reuse the completed future instead of waiting for the new operation. A stale timeout callback could also remove a replacement entry by key.Because the state event has already been published, this race does not normally stop the underlying split or unload operation. It affects completion tracking: a retry for the same bundle can return the previous request's result before the new operation completes. In a narrower race, stale cleanup can remove the new request's tracking entry, causing the caller or scheduler to wait until the configured timeout (60 seconds by default) and report a failure even if the underlying operation succeeds.
Modifications
remove(bundle, future)so a stale callback cannot remove a newer request.Verifying this change
This change added and extended unit tests and was verified locally with:
./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.loadbalance.extensions.manager.SplitManagerTest --tests org.apache.pulsar.broker.loadbalance.extensions.manager.UnloadManagerTest./gradlew :pulsar-broker:checkstyleMain :pulsar-broker:checkstyleTest./gradlew quickCheckgit diff --checkDoes this pull request potentially affect one of the following parts: