Skip to content

[improve][broker] Avoid blocking joins in ClusterResources sync APIs - #26295

Open
VedantMadane wants to merge 1 commit into
apache:masterfrom
VedantMadane:improve-resources-cluster-sync-cleanup-22544
Open

[improve][broker] Avoid blocking joins in ClusterResources sync APIs#26295
VedantMadane wants to merge 1 commit into
apache:masterfrom
VedantMadane:improve-resources-cluster-sync-cleanup-22544

Conversation

@VedantMadane

Copy link
Copy Markdown

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.isClusterUsed was one of the clearer offenders: it called MetadataCache.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 isClusterUsedAsync in ClustersBase.

Modifications

In ClusterResources:

  1. isClusterUsed now wraps isClusterUsedAsync with the standard operationTimeoutSec (same pattern as other BaseResources sync helpers).
  2. getNamespacesForClusterAsync added; sync getNamespacesForCluster routes through it with timeout.
  3. In isClusterUsedAsync, after FutureUtil.waitForAll, use getNow instead of join so 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

  • Make sure that the change passes the CI checks.

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:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant