Skip to content

[fix](auth) Check external catalog visibility before SHOW DATABASES - #69612

Merged
Gabriel39 merged 1 commit into
apache:masterfrom
Gabriel39:fix/external-show-databases-auth
Oct 26, 2026
Merged

Gabriel39 merged 1 commit into
apache:masterfrom
Gabriel39:fix/external-show-databases-auth

Conversation

@Gabriel39

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

SHOW DATABASES could call an external catalog's metadata service before checking whether the caller could see that catalog. A caller with no privileges could trigger remote initialization and receive connection errors.

Check catalog visibility before listing databases or planning the WHERE form. Reuse the existing SHOW predicate, which includes database, table and column grants and honors the configured authorization controller. Keep the existing per-database filtering and internal-catalog behavior.

Release note

Check external catalog visibility before accessing metadata for SHOW DATABASES.

Validation

  • Compiled the changed command and test against cached master dependencies; all 6 ShowDatabasesCommandTest tests passed.
  • Confirmed the new unauthorized-access test failed on the original command before applying the fix.
  • FE Checkstyle passed with zero violations.
  • No live Ranger integration test or full FE test suite was run locally.

Check List (For Author)

  • Test: Unit Test
  • Behavior changed: Yes. Callers without external catalog visibility receive access denied before remote metadata access.
  • Does this need documentation? No.

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete two-file PR at commit 199dce7. No actionable new findings or existing blocking comments were identified.

Checkpoint conclusions:

  1. Goal and evidence: external catalog visibility is checked before remote database listing and WHERE planning. Unit cases cover explicit/default/LIKE/WHERE rejection, database filtering, internal bypass, missing catalogs, and native database/table/column grants; inspected only.
  2. Scope and reuse: the focused command/test patch reuses existing authorization and error APIs.
  3. Concurrency and locks: no new threads, shared state, or locks; existing native authorization read locks end before connector metadata access.
  4. Lifecycle and initialization: no new owned resource, cleanup requirement, or static initialization dependency.
  5. Configuration: no additions; existing skip_catalog_priv_check behavior is preserved.
  6. Compatibility: no signature or storage-format change. Access-denied errors for invisible external catalogs are intentional; internal and inherited native visibility remain supported.
  7. Thrift/protobuf: unchanged; field-ID compatibility review is not applicable.
  8. Parallel paths: plain, LIKE, default-catalog, and WHERE forms share the gate. It matches SHOW CATALOGS visibility policy. Global Ranger inherits descendant visibility; catalog-bound sources retain documented catalog-check/skip behavior. Cloud and classic use the same command path.
  9. Special conditions: the internal bypass is explained and tested; missing catalogs fail explicitly. Using the supplied ctx for database checks matches command invocation ownership.
  10. Coverage: meaningful negative and filtered-result tests are present. Static tracing also covered permitted WHERE planning, selected-catalog schema scanning, and database filtering; no unresolved code candidate remains.
  11. Expected results: asserted visible rows are consistent with filtering and deterministic ordering; no golden output files changed.
  12. Observability and errors: existing error 5087 names the user/catalog and propagates through the command error boundary; no added long-running operation requires metrics.
  13. Transactions, persistence, and failover: no affected write or EditLog path.
  14. Data writes and atomicity: no data mutation introduced.
  15. FE-BE variable propagation: no new field or send path.
  16. Performance: one catalog authorization check per external invocation; no new remote metadata request or asymptotic regression identified.
  17. Other invariants: no optimizer-rule, slot, physical-property, partition-version, delete-bitmap, or BE memory-ownership change. Denial follows the existing failure-reporting convention.

User focus: no additional focus points were supplied.

Validation limits: static review only, as instructed. No builds or tests were run. The added unit tests do not execute a permitted WHERE query or live Ranger/connector integration, and no runtime verification is claimed. Both independent reviewers returned NO_NEW_VALUABLE_FINDINGS; all initial risk points have evidence-backed dispositions and no static coverage gaps remain.

Review converged after 1 round(s).

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28716 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 199dce77e1972d9cbc97c3790547c8dd9aacedf0, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17656	5172	5090	5090
q2	2186	307	273	273
q3	10203	1395	812	812
q4	4689	471	336	336
q5	7449	810	526	526
q6	180	183	158	158
q7	785	795	591	591
q8	9240	1360	1099	1099
q9	5531	4206	4169	4169
q10	6830	1291	1025	1025
q11	427	250	234	234
q12	642	399	276	276
q13	18110	3627	3023	3023
q14	266	272	251	251
q15	q16	719	717	660	660
q17	1184	765	569	569
q18	7082	6182	6115	6115
q19	1134	963	600	600
q20	384	326	226	226
q21	5846	2471	2414	2414
q22	382	325	269	269
Total cold run time: 100925 ms
Total hot run time: 28716 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5960	5995	6432	5995
q2	747	610	611	610
q3	5507	5779	5406	5406
q4	2026	2175	1561	1561
q5	5663	5551	5838	5551
q6	249	190	139	139
q7	2339	2007	1817	1817
q8	3065	2686	2623	2623
q9	7897	8052	7762	7762
q10	3651	3588	3162	3162
q11	597	412	384	384
q12	704	680	520	520
q13	3277	3631	3013	3013
q14	286	299	263	263
q15	q16	674	689	610	610
q17	7750	7035	6887	6887
q18	13019	12257	12879	12257
q19	907	771	780	771
q20	2148	2151	1923	1923
q21	5774	4647	4877	4647
q22	485	457	394	394
Total cold run time: 72725 ms
Total hot run time: 66295 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 150401 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 199dce77e1972d9cbc97c3790547c8dd9aacedf0, data reload: false

query5	4308	584	424	424
query6	422	205	209	205
query7	4815	457	229	229
query8	344	170	152	152
query9	8782	3105	3107	3105
query10	478	307	267	267
query11	6018	3886	3563	3563
query12	155	93	90	90
query13	1270	451	325	325
query14	6152	3930	3625	3625
query14_1	3429	3420	3424	3420
query15	211	201	187	187
query16	951	429	358	358
query17	879	674	541	541
query18	2432	432	316	316
query19	218	165	141	141
query20	86	84	86	84
query21	213	126	107	107
query22	13066	13031	12856	12856
query23	13457	12989	12403	12403
query23_1	12598	12505	12430	12430
query24	7382	809	476	476
query24_1	480	481	475	475
query25	533	423	366	366
query26	1257	265	143	143
query27	2764	440	276	276
query28	4619	1938	1912	1912
query29	1556	573	432	432
query30	299	230	197	197
query31	997	924	818	818
query32	155	87	88	87
query33	509	288	239	239
query34	903	848	480	480
query35	721	746	636	636
query36	831	784	757	757
query37	115	94	77	77
query38	1777	1722	1654	1654
query39	805	782	740	740
query39_1	731	726	731	726
query40	219	111	92	92
query41	66	63	61	61
query42	84	83	82	82
query43	339	357	318	318
query44	1312	687	688	687
query45	183	181	168	168
query46	809	970	564	564
query47	2801	2580	2824	2580
query48	292	302	210	210
query49	570	397	293	293
query50	681	269	205	205
query51	10401	10492	10524	10492
query52	81	81	74	74
query53	184	211	148	148
query54	230	193	179	179
query55	70	68	64	64
query56	242	228	208	208
query57	1656	1662	1582	1582
query58	291	272	283	272
query59	2126	2072	1933	1933
query60	278	246	223	223
query61	144	143	135	135
query62	396	327	291	291
query63	180	155	153	153
query64	2721	926	749	749
query65	3324	3274	3240	3240
query66	1784	416	317	317
query67	20257	20215	19853	19853
query68	3175	993	607	607
query69	383	298	246	246
query70	864	789	810	789
query71	306	232	209	209
query72	2817	2610	2318	2318
query73	526	520	288	288
query74	4658	4544	4332	4332
query75	2315	2264	1914	1914
query76	2340	1016	593	593
query77	359	431	262	262
query78	9604	9600	9200	9200
query79	970	850	503	503
query80	1221	414	348	348
query81	585	322	275	275
query82	902	126	105	105
query83	293	204	182	182
query84	311	130	94	94
query85	873	434	373	373
query86	399	239	227	227
query87	2023	1937	1835	1835
query88	3669	2669	2654	2654
query89	331	283	240	240
query90	1906	166	162	162
query91	166	154	123	123
query92	99	95	92	92
query93	1035	988	577	577
query94	655	309	276	276
query95	567	317	373	317
query96	663	476	230	230
query97	2456	2443	2353	2353
query98	165	152	149	149
query99	774	767	643	643
Total cold run time: 235665 ms
Total hot run time: 150401 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.34 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 199dce77e1972d9cbc97c3790547c8dd9aacedf0, data reload: false

query1	0.01	0.01	0.01
query2	0.11	0.05	0.04
query3	0.26	0.09	0.09
query4	1.60	0.09	0.10
query5	0.23	0.24	0.25
query6	1.17	0.69	0.67
query7	0.04	0.01	0.01
query8	0.05	0.04	0.03
query9	0.38	0.35	0.36
query10	0.60	0.57	0.62
query11	0.20	0.15	0.14
query12	0.18	0.15	0.14
query13	0.49	0.50	0.51
query14	1.03	1.03	1.02
query15	0.64	0.60	0.62
query16	0.34	0.35	0.34
query17	1.18	1.14	1.11
query18	0.21	0.19	0.19
query19	2.13	1.97	1.97
query20	0.02	0.01	0.01
query21	15.46	0.21	0.15
query22	4.75	0.06	0.05
query23	16.27	0.31	0.12
query24	2.99	0.57	0.41
query25	0.12	0.06	0.05
query26	0.80	0.20	0.15
query27	0.06	0.04	0.03
query28	3.60	0.82	0.37
query29	12.50	4.24	3.26
query30	0.28	0.13	0.09
query31	2.78	0.55	0.32
query32	3.23	0.60	0.51
query33	3.17	3.20	3.18
query34	15.47	4.01	3.39
query35	3.32	3.34	3.35
query36	0.54	0.45	0.44
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.19	0.14	0.15
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.74 s
Total hot run time: 24.34 s

@Gabriel39
Gabriel39 merged commit 61d1aef into apache:master Oct 26, 2026
37 of 38 checks passed
@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.49% (3/611) 🎉
Increment coverage report
Complete coverage report

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

Gabriel39 added a commit to Gabriel39/incubator-doris that referenced this pull request Oct 29, 2026
Apply the outstanding changes in master merge order:
apache#69545 7d16729
apache#69551 7224a2d
apache#69612 61d1aef
apache#69615 8d2bd1e
apache#69650 3dc7341
apache#69651 c00ecb1
apache#69646 e493c61
apache#69668 7865646

apache#69614 already exists on branch-4.2 through apache#69644.
Adapt datasource APIs and tests to the release branch, retaining its
existing scanner dispatch and statement-bound metadata contracts.
yiguolei pushed a commit that referenced this pull request Oct 30, 2026
### What problem does this PR solve?

Backport the requested external-data and FileScannerV2 changes to
`branch-4.2` in their actual master merge order:

| Order | Master PR | Change | Backport |
| --- | --- | --- | --- |
| 1 | #69545 | Preserve Paimon schema options after field renames |
Included |
| 2 | #69551 | Expand Iceberg capability, transaction and snapshot tests
| Included with 4.2 API adaptations |
| 3 | #69614 | Elasticsearch HTTP scans in FileScannerV2 | Already
present through #69644 (`2104b7509cda`); not applied twice |
| 4 | #69612 | Check catalog visibility before SHOW DATABASES accesses
metadata | Included |
| 5 | #69615 | Publish Iceberg Parquet split offsets | Included |
| 6 | #69650 | Preserve ES compound residuals and expand scanner
coverage | Included |
| 7 | #69651 | Accept Elasticsearch 9.x during node discovery | Included
|
| 8 | #69646 | Prioritize Parquet V2 row groups using TopN bounds |
Included |
| 9 | #69668 | Arrow loads and schema inference in FileScannerV2 |
Included |

The eight outstanding changes are combined in one commit. This branch
retains the 4.2 FE datasource APIs instead of importing master's
connector-module refactor.

### Backport adaptations

- Port Paimon schema restoration, catalog-option provenance, fallback
handling and tests to the existing table-copy/serialization lifecycle.
Keep statement-bound fields when reader options are applied after a
schema-only rename.
- Exercise Iceberg's existing metadata and transaction entry points with
real in-memory tables and retained-generation fixtures. Preserve the
nine disabled known-bug reproductions; omit two connector-only lifecycle
tests. Expiration checks verify live data-file sets and exact
delete-file counters; 4.2's separate manifest-name/data-counter issue
remains unchanged. The delete/history SQL suite checks visible rows and
eager/late-materialization parity because 4.2 does not expose master's
`_file`/`_pos` columns. The inventory labels upstream-only evidence
explicitly.
- Port ES residual tracking to the legacy planner and add compound
OR/NOT, docvalue eligibility and Thrift-context tests there. Use Java
8-compatible HTTP APIs for opt-in ES 9 tests and the branch's supported
node-address fixtures.
- Keep the existing full-schema Iceberg metadata-table scan, which
already supplies the file-size dependency for split offsets. Adapt the
external write suite to verify offsets without requiring master-only
distribution plans or golden output.
- Use the existing Parquet statistics interface and physical
row-location representation. Keep the TopN scheduling and pruning
invariants.
- Include the shared Arrow array normalizer required by the new reader,
taken from the same master revision. Preserve 4.2 Lance/Avro dispatch;
omit the schema-inference test for the unavailable Hive OpenCSV parser.

### Validation

- FE production and test sources compile with the branch's Java 8
target. Across the targeted runs and focused reruns, 20 test classes
report 181 discovered, 171 passed, zero failures/errors, and 10 skipped:
nine intentionally disabled known-bug reproductions plus the opt-in live
ES 9 class.
- FE Checkstyle: passed with zero violations.
- Clang compiler syntax checks: all 23 affected C++ translation units
passed against the current sources and freshly generated Thrift, using
cached third-party/generated build dependencies. Focused BE runtime
validation is listed below.
- clang-format 16: all 30 affected C++ source/header files passed.
- Groovy 4.0.19 syntax and AST conversion: all seven changed suites
passed. All 105 local inventory links resolve.
- Complete staged-diff self-review, whitespace/conflict checks, and
sensitive-information checks passed.

A full BE rebuild and SQL/external-service regressions were not run
locally. Live ES 9 tests require their opt-in endpoint. CI is requested
for the combined backport.

### Release note

Fix Paimon reads after field renames, external-catalog SHOW DATABASES
authorization, and ES compound residual filtering. Support ES 9.x node
discovery, publish Iceberg Parquet split offsets, improve Parquet V2
TopN row-group scheduling, and use FileScannerV2 for Arrow loads and
text/JSON schema inference.

### Check List (For Author)

- Test
    - [x] Unit Test
- [x] Regression test additions and syntax checks; SQL execution pending
CI
- Behavior changed:
    - [x] Yes. Backport the changes listed above.
- Does this need documentation?
- [x] No. Existing interfaces and settings are retained; the test
coverage inventory is included.

### Follow-up fixes

- Set the Thrift `enable_file_scanner_v2` default to `true`, matching
the session default. Preserve explicit `false` for legacy query scans
and extend the existing load-selection test.
- Keep the selected Paimon snapshot and schema together during relation
projection. Historical sequence/aggregation options must not be combined
with the latest field names. Read-only principals can resolve historical
selectors without INSERT permission.
- Read legacy append schemas with missing or empty bucket keys without
bucket pruning, preserving every historical file. The regression covers
both unaware and multiple fixed buckets.

Follow-up validation: 169 targeted Paimon FE tests passed with zero
failures/errors/skips. FE production compilation and Checkstyle passed.
Both changed C++ test translation units passed compiler syntax checks
and clang-format 16. Regenerated Java/C++ defaults are enabled; a Java
8-targeted protocol check verifies constructor/clear defaults, an
omitted wire field, and an explicit-false round trip. Complete BE CI and
live external SQL suites remain pending.

The two new reproductions first failed with the same missing-bucket-key
and renamed-sequence-field errors as CI. A separate read-only-principal
reproduction also failed before the permission correction. Complete
external regression execution remains pending CI.

### BE unit-test compatibility

- Complete the native Arrow Variant input dependency for `branch-4.2`:
accept binary storage and the Parquet Variant extension, validate
metadata and payloads before appending, and retain owned data after
Arrow buffers are released. Allow that ingestion path through the load
reader while preserving query-format restrictions and source-default
validation.
- Preserve Variant V2 markers in the Arrow test fixtures, including
nested types. Verify timestamp input against this branch's SerDe for
positive, negative, and second-boundary values. Match the existing DATE
range diagnostic in the TopN pruning test.
- Add tests for sliced and empty reads, invalid ranges and carriers,
malformed metadata/payloads, NULL children, atomic failure, buffer
ownership, and the query capability boundary.

Validation: all 13 previously failing BE tests passed. The expanded run
passed all 309 tests across nine suites, including Arrow/JSON loads,
load validation, Iceberg, table mapping, and Variant input/output. The
focused executable rebuilds the affected readers and SerDe against
cached 4.2 build dependencies; this is not a complete BE rebuild. All
seven changed C++ translation units passed compiler checks with current
headers/generated Thrift, and all 33 affected C/C++ files passed
clang-format 16. The complete staged diff, whitespace, and
sensitive-information checks passed. Full CI is requested with `run
buildall` and `/review`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.2.0-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants