[Feature](functions) add brokers tvf function to query broker cluster info#60323
[Feature](functions) add brokers tvf function to query broker cluster info#60323heguanhui wants to merge 1 commit into
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
6a762b4 to
524c19c
Compare
|
run buildall |
524c19c to
9fce5e8
Compare
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 32499 ms |
ClickBench: Total hot run time: 27.75 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 31979 ms |
ClickBench: Total hot run time: 27.81 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
7147271 to
fc86655
Compare
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 32413 ms |
ClickBench: Total hot run time: 27.66 s |
|
run buildall |
TPC-H: Total hot run time: 32259 ms |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
ClickBench: Total hot run time: 27.94 s |
FE UT Coverage ReportIncrement line coverage |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
ClickBench: Total hot run time: 25.74 s |
FE UT Coverage ReportIncrement line coverage |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
19b7c92 to
7baf965
Compare
|
run buildall |
TPC-H: Total hot run time: 29491 ms |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-DS: Total hot run time: 173353 ms |
ClickBench: Total hot run time: 25.98 s |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
|
/review |
There was a problem hiding this comment.
I found several issues that should be fixed before merge.
Critical checkpoint conclusions:
- Goal/test: The PR adds a
brokers()TVF and tests, but the implementation does not fully match existing broker metadata auth or name semantics, and the tests miss important edge cases. - Scope: The feature is small, but it crosses broker metadata authorization and FE/BE metadata-scan compatibility boundaries.
- Concurrency/lifecycle: No new concurrency or lifecycle state issue found; broker reads still use existing
BrokerMgrpaths. - Configuration/persistence/writes: No new configs or persisted state found.
- Compatibility: The new metadata enum can silently return empty rows on old BEs during rolling upgrade.
- Parallel paths:
SHOW BROKERandSHOW PROC '/brokers'remain stricter than the TVF, and exact broker-name APIs conflict with the TVF's case-insensitive filter behavior. - Testing: Current tests cover happy paths but miss uppercase-key filtering, case-distinct broker names, auth parity, and unsupported metadata behavior.
- Observability/performance: No separate observability or performance issue found beyond the existing metadata scan path.
Subagent conclusions: MAIN-2 came from TEST-1; MAIN-3 and MAIN-4 came from OPT-1 and OPT-2; MAIN-1 was added by the main review. Both live subagents completed convergence round 1 with NO_NEW_VALUABLE_FINDINGS for this final comment set.
User focus: no additional user-provided review focus.
Validation: static review only. This checkout lacks thirdparty/installed and thirdparty/installed/bin/protoc, so I did not run FE/BE builds or regression tests.
| if (params == null) { | ||
| throw new AnalysisException("params cannot be null"); | ||
| } | ||
| String originalClusterName = params.get(CLUSTER_NAME); |
There was a problem hiding this comment.
CLUSTER_NAME is accepted by the validation loop below, but this lookup is case-sensitive and runs before any normalization. For brokers("CLUSTER_NAME" = "missing"), originalClusterName stays null, getMetaScanRange() sends a null filter, and the scan returns all brokers instead of zero rows. The new regression case with uppercase CLUSTER_NAME does not catch this because it uses the existing test cluster and expects all three rows. Please normalize the property map before lookup, as the other metadata TVFs do, and add a case where uppercase CLUSTER_NAME must filter something out.
There was a problem hiding this comment.
I fixed it already.
| if (StringUtils.isBlank(originalClusterName)) { | ||
| throw new AnalysisException("Invalid brokers param value: " + originalClusterName); | ||
| } | ||
| clusterName = originalClusterName.toLowerCase(); |
There was a problem hiding this comment.
This changes the semantics of broker names from exact to case-insensitive only for the TVF. Add/drop and lookup paths preserve the broker name text and use exact map keys in BrokerMgr, so BrokerA and brokera can be distinct broker names. After this lowercasing, MetadataGenerator.brokersMetadataResult() compares with equalsIgnoreCase, so brokers("cluster_name" = "BrokerA") would return both clusters. Please preserve the original filter value and compare broker names consistently with the existing broker manager APIs.
There was a problem hiding this comment.
I fixed it already.
| + " only support property [" + CLUSTER_NAME + "]"); | ||
| } | ||
| } | ||
| if (!Env.getCurrentEnv().getAccessManager().checkDbPriv(ConnectContext.get(), |
There was a problem hiding this comment.
This privilege check is weaker than the existing broker metadata surfaces. SHOW BROKER gates the same BrokerMgr.getBrokersInfo() data behind global ADMIN or OPERATOR/NODE, and SHOW PROC '/brokers' requires ADMIN_OR_NODE, but this TVF only requires SELECT on internal.information_schema. New users get that information_schema SELECT in their default role, so select * from brokers() would expose broker names, hosts, ports, liveness, and errors to users who cannot run SHOW BROKER. Please align the TVF auth with the existing broker command/proc privilege before returning these rows.
There was a problem hiding this comment.
I fixed it already.
| PAIMON = 12, | ||
| PARQUET = 13, | ||
| STREAMS = 14, | ||
| BROKERS = 15, |
There was a problem hiding this comment.
This new metadata type needs a compatibility gate or a failure path for mixed FE/BE versions. A new FE will build a TMetaScanRange with BROKERS and MetadataScanNode sends it to whatever query backend FederationBackendPolicy selects. If that BE is still old during rolling upgrade, it does not have the BROKERS case and MetaScanner::_fetch_metadata() takes the default path that sets EOF and returns OK, so brokers() can silently return no rows. Please either route/gate this TVF to BEs that support the new type or make unsupported metadata types fail loudly instead of succeeding with an empty result.
There was a problem hiding this comment.
Thanks for the suggestion. However, currently none of the other TVFs handle upgrade compatibility either. To keep consistency with existing implementations, we won’t address it separately in this PR for now. If there is a unified upgrade compatibility solution in the future, we can support it then.
There was a problem hiding this comment.
brokersMetadataResult() is missing the ADMIN check that backends()/frontends() do in MetadataGenerator — so a SELECT-only user can read broker info here, while SHOW BROKER requires ADMIN/OPERATOR. Please add checkGlobalPriv(currentUserIdentity, PrivPredicate.ADMIN) (return empty for non-admin) as the sibling TVFs do, plus a non-admin regression case.
Also NonConcurrent Regression is red — please confirm it's unrelated before merge.
bc1db5a to
7461c94
Compare
|
run buildall |
7461c94 to
ed246ba
Compare
ed246ba to
7fe7a59
Compare
|
run buildall |
1 similar comment
|
run buildall |
|
/review |
There was a problem hiding this comment.
Automated review for PR #60323.
Requested changes:
- The new brokers TVF regression test is not isolated from global broker state; see the inline comment.
Critical checkpoint conclusions:
- Goal: the PR adds a
brokers()metadata TVF across Nereids registration, catalog TVF construction, FE metadata generation, BE meta scan forwarding, thrift, and tests. The core path is present, but the regression test has a blocking isolation issue. - Scope: the implementation is focused on the new TVF and required metadata plumbing.
- Concurrency/lifecycle: broker rows are read through
BrokerMgr.getBrokersInfo()under the existing broker-manager lock; no new lifecycle or lock ordering issue was found. - Configuration/compatibility: no new config item. The mixed FE/BE metadata enum compatibility concern is already covered by existing thread 3526269320, so I did not duplicate it.
- Parallel paths/protocol: checked Nereids binding/visitor registration,
TableValuedFunctionIf,MetadataScanNode, BEMetaScanner, FEMetadataGenerator, and thrift fields. The broker-name exactness issue is already covered by existing thread 3526269314. - Tests: FE unit and regression coverage were added, but the regression suite currently assumes no unrelated brokers exist globally. I could not run FE/BE tests in this runner because
.worktree_initialized,thirdparty/installed, andthirdparty/installed/bin/protocare missing in the shallow checkout. - User focus: no additional user-provided focus was specified.
Subagent conclusions:
optimizer-rewrite:OPT-1was merged as duplicate of existing thread 3526269314; no new non-duplicate optimizer/rewrite finding.tests-session-config:TEST-2was accepted as the inline comment below;TEST-1was merged as duplicate of existing thread 3526269314.- Convergence Round 1 ended with both live subagents returning
NO_NEW_VALUABLE_FINDINGSfor the same final ledger/comment set.
| def columnsExpr = String.join(",", columns) | ||
| log.info("columns expr: ${columnsExpr}") | ||
|
|
||
| def brokers = sql """select ${columnsExpr} from brokers()""" |
There was a problem hiding this comment.
This makes the suite depend on the whole FE broker registry being empty before it owns any state. brokers() and show broker return global broker metadata, while other regression suites and manual/debug runs can leave unrelated broker names behind. In that case these initial size() == 0 assertions fail even though the new TVF works for this test's broker cluster. Please make the setup and assertions scoped to brokers_tvf_test_cluster: drop that name before starting, assert brokers("cluster_name" = brokerClusterName) is empty before add, and avoid asserting that the entire broker registry has no rows.
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 35684 ms |
ClickBench: Total hot run time: 25.68 s |
What problem does this PR solve?
add brokers tvf function to query broker cluster info
1、same performance as show broker command
2、same performance as show proc '/brokers' command
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)