[improve][broker] Avoid blocking joins in ClusterResources sync APIs - #26295
Open
VedantMadane wants to merge 1 commit into
Open
[improve][broker] Avoid blocking joins in ClusterResources sync APIs#26295VedantMadane wants to merge 1 commit into
VedantMadane wants to merge 1 commit into
Conversation
ClusterResources.isClusterUsed used MetadataCache.getChildren().join() without a timeout, which can block caller threads (and risk metadata thread starvation if used from completion paths). - Implement isClusterUsed via isClusterUsedAsync with operation timeout - Add getNamespacesForClusterAsync; route sync method through it - After waitForAll in isClusterUsedAsync, use getNow instead of join Part of apache#22544
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.
Main Issue: #22544
Motivation
Issue #22544 asks to clean up synchronous metadata access in the broker resources layer so callers cannot easily block metadata store threads.
ClusterResources.isClusterUsedwas one of the clearer offenders: it calledMetadataCache.getChildren(...).join()in a loop with no operation timeout, and did sequential metadata RPCs instead of using the existing parallel async path.Related background: #22542 (closed) discussed not chaining heavy sync metadata work after metadata completions; admin already uses
isClusterUsedAsyncinClustersBase.Modifications
In
ClusterResources:isClusterUsednow wrapsisClusterUsedAsyncwith the standardoperationTimeoutSec(same pattern as otherBaseResourcessync helpers).getNamespacesForClusterAsyncadded; syncgetNamespacesForClusterroutes through it with timeout.isClusterUsedAsync, afterFutureUtil.waitForAll, usegetNowinstead ofjoinso a future refactor cannot reintroduce blocking.This is intentionally scoped (one resources class / one class of bugs). Broader removal of all sync resource APIs remains future work under #22544.
Verifying this change
This change is a focused rework of existing APIs without new behavior beyond timeout + non-blocking composition. Existing admin paths already use
isClusterUsedAsync.Does this pull request potentially affect one of the following parts: