Skip to content

[fix](fe) Skip HMS database events that include/exclude_database_list filters out - #70165

Merged
morningman merged 1 commit into
apache:masterfrom
morningman:b2m-t50-hms-event-db-filter
Nov 5, 2026
Merged

morningman merged 1 commit into
apache:masterfrom
morningman:b2m-t50-hms-event-db-filter

Conversation

@morningman

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #67417, #68196

Problem Summary:

In short. This ports from branch-4.x #67417 and #68196 the check that keeps a metastore event from adding a database that include_database_list or exclude_database_list keeps out of an HMS catalog. On master, a CREATE DATABASE event for such a database puts it into the catalog's database list on every FE that applies the event: SHOW DATABASES lists it and queries can reach it until the list is reloaded.

Background. A catalog lists its databases through ExternalCatalog#getFilteredDatabaseNames, which drops a remote database that exclude_database_list names or, when include_database_list is set, one that it does not name. On an HMS catalog with hive.enable_hms_events_incremental_sync, MetastoreEventSyncDriver applies the metastore's events on every FE. A CREATE DATABASE event, and the new name of an ALTER DATABASE rename, reach PluginDrivenExternalCatalog#registerDatabaseFromEvent, which adds the database to the cached database names. branch-4.1 and branch-4.2 have checked the two lists for these events since #67417.

The problem, and what it cost. registerDatabaseFromEvent adds the database without the check. A database that the catalog is configured to hide then shows in SHOW DATABASES, USE and queries reach it (privileges still apply), and table events register tables in it. It goes away only when the cached names are reloaded: after external_cache_refresh_time_minutes (10 by default), on a lookup of a name that is not cached, on REFRESH CATALOG, or after a restart.

How this PR fixes it. The check moves out of getFilteredDatabaseNames into ExternalCatalog#isDatabaseListed, which the listing and registerDatabaseFromEvent share; an event for a database the lists keep out returns before it touches any cache. Like the listing, the check compares the remote name exactly. Not ported from branch-4.x: skipping the table, partition and refresh events of such databases, a performance item (on master they find no database and return, after one reload of the names), and comparing names ignoring case when lower_case_database_names is not 0, which would change the listing as well.

Results.

Event, with the database names cached Before After
CREATE DATABASE archived, exclude_database_list = archived archived listed not listed
CREATE DATABASE other, include_database_list = sales,sales2 other listed not listed
CREATE DATABASE sales2, allowed by either list listed listed

Original author: @924060929

Release note

An HMS catalog with incremental metastore event sync no longer lists a newly created database that include_database_list or exclude_database_list filters out.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason

    New PluginDrivenExternalCatalogEventFilterTest runs the three events of the table on a catalog whose database names are cached: both cases fail without the check, with the filtered-out database in the names. ExternalCatalogTest (50), PluginDrivenExternalCatalogIdentityTest, PluginDrivenExternalCatalogDdlRoutingTest (90) and the MetastoreEventSyncDriver rename, mapped name and seeding tests pass, and fe-core Checkstyle reports nothing. The end-to-end path needs a Hive metastore with event notifications, which was not run locally.

  • Behavior changed:

    • No.
    • Yes.
      A metastore event no longer adds a database that the catalog's include_database_list or exclude_database_list keeps out.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

… filters out

### What problem does this PR solve?

Issue Number: None

Related PR: apache#67417, apache#68196

Problem Summary: A catalog lists its databases through
getFilteredDatabaseNames, which drops a remote database that
`exclude_database_list` names or, when `include_database_list` is set,
one it does not name. On an HMS catalog with
`hive.enable_hms_events_incremental_sync`, a CREATE DATABASE event (and
the new name of an ALTER DATABASE rename) reaches
PluginDrivenExternalCatalog#registerDatabaseFromEvent, which added the
database to the cached database names without that check: on every FE
that applies the event, SHOW DATABASES lists it and queries can use it
until the names are reloaded (external_cache_refresh_time_minutes, 10 by
default, REFRESH CATALOG or a restart). branch-4.x skips such events
since apache#67417.

The check moves into ExternalCatalog#isDatabaseListed, which the listing
and registerDatabaseFromEvent share; an event for a database the lists
keep out returns before it touches any cache. Like the listing, it
compares the remote name exactly. Not ported: skipping the table,
partition and refresh events of such databases (on master they find no
database and return), and comparing names ignoring case when
lower_case_database_names is not 0, which would change the listing too.

### Release note

An HMS catalog with incremental metastore event sync no longer lists a
newly created database that include_database_list or
exclude_database_list filters out.

### Check List (For Author)

- Test: Unit Test
    - New PluginDrivenExternalCatalogEventFilterTest: with the names
      cached, an event for a database that either list keeps out leaves
      them unchanged, and one for an allowed database adds it; both cases
      fail without the check.
    - ExternalCatalogTest, PluginDrivenExternalCatalogIdentityTest,
      PluginDrivenExternalCatalogDdlRoutingTest and the
      MetastoreEventSyncDriver tests pass.
- Behavior changed: Yes. An HMS event no longer adds a database that the
  catalog's include/exclude database lists keep out.
- Does this need documentation: No

Co-authored-by: 924060929 <lanhuajian@selectdb.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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?

@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman

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 all three changed files at head 20efa876dbac76deccca01cf695ffee8cfae17d3. No new actionable findings. No existing inline review findings were present to retain or duplicate. No additional user focus was supplied.

The traced flow is metastore CREATE / rename target -> MetastoreEventSyncDriver -> CatalogMgr -> registerDatabaseFromEvent -> shared remote-name predicate -> database/cache publication. Rename removes the old local identity first; connector invalidation runs before registration.

Critical checkpoint conclusions:

  • Goal and proving tests: The guard prevents include/exclude-filtered databases entering the cached names through events. The two added JUnit tests cover each denial mode and allowed insertion into a hot snapshot; their assertions would expose the previous insertion behavior. This is static assessment, not a test-run result.
  • Scope and reuse: The change is focused. The extracted predicate is equivalent to the previous listing lambda and is reused by event registration.
  • Concurrency and locking: The event daemon can overlap query loads and catalog ALTER/refresh. Predicate maps are local; no new lock or lock-order edge is added. Existing catalog reset and guarded cache publication remain in place. No new concurrency defect was substantiated.
  • Lifecycle: Rejected events return before database construction. Allowed events retain existing finally invalidation. ALTER retires cache owners and invalidates names/object generations; no new resource or static-initialization dependency is introduced.
  • Configuration: No new item. Existing include/exclude properties are read when applying an event and retain the existing ALTER/reset behavior.
  • Compatibility: No storage, journal, wire format or existing method signature is changed. Older FEs retain their previous event behavior until upgraded.
  • Thrift/protobuf: Not applicable; no definitions change.
  • Parallel paths: Cached and session-bypass listing share the filter. CREATE and database rename use the guarded registration; DROP still removes state. Table/partition paths cannot register a missing filtered database.
  • Special conditions: Remote names are filtered before local mapping, exactly as in listing. Exclude precedence, empty-list behavior, case-sensitive comparison and the information_schema/mysql exemptions are preserved. The guard's comment explains its purpose.
  • Test coverage: Inspected the new positive/negative tests and existing listing, identity, mapping, rename, seeding and cache-publication tests. The new fixture genuinely warms names, and its allowed name is absent from the remote listing, so successful insertion depends on the event path. Live HMS and concurrent runtime behavior were not exercised.
  • Test results: No expected-output files change. New assertions match the intended behavior; no test pass is claimed by this review.
  • Observability: Ignoring configured-out databases is expected behavior. Existing descriptor/catalog failure context is retained; no additional metric or log is needed for this small predicate guard.
  • Transactions and persistence: No new journal payload or transaction operation. Existing ordered per-FE application and master cursor replication remain unchanged; ignored registration completes normally before cursor advancement.
  • Data writes and crash atomicity: No user-data write is added. Accepted events keep existing names/object/index publication; rejected events publish nothing. No new crash-recovery defect was identified.
  • FE/BE variable passing: Not applicable; no transmitted variable changes.
  • Performance: Listing still parses filters once and scans the names once. Database-event registration parses the two lists, then avoids database/cache work for rejected events. No material performance issue was found.
  • Other core invariants: No substantiated metadata-visibility, error-propagation or ownership regression was found. Partition versions, delete bitmaps and BE memory accounting are outside the changed behavior.

Both initial risk focuses were dismissed with code evidence: event identity matches listing identity, and the early return does not bypass rename removal or preceding connector invalidation. There are no unresolved code candidates or uncovered changed files. Validation limits: static inspection only; no builds, tests, benchmarks, or live HMS integration were run.

Review converged after 2 round(s).

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 100.00% (11/11) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17602	5208	5030	5030
q2	2186	302	255	255
q3	10221	1403	835	835
q4	4682	472	344	344
q5	7424	827	529	529
q6	183	189	157	157
q7	754	823	602	602
q8	9257	1360	1140	1140
q9	5561	4280	4236	4236
q10	6820	1290	1046	1046
q11	426	243	235	235
q12	641	406	278	278
q13	18095	3632	3014	3014
q14	274	272	251	251
q15	q16	723	723	647	647
q17	1195	744	572	572
q18	6977	6182	6130	6130
q19	1249	965	617	617
q20	389	342	228	228
q21	6217	2459	2442	2442
q22	390	326	265	265
Total cold run time: 101266 ms
Total hot run time: 28853 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5940	5917	6124	5917
q2	749	592	573	573
q3	5658	6376	5348	5348
q4	2006	2156	1562	1562
q5	5686	5804	5610	5610
q6	246	187	149	149
q7	2260	2030	1835	1835
q8	3031	2780	2751	2751
q9	7964	7472	7483	7472
q10	3649	3597	3127	3127
q11	596	439	389	389
q12	715	665	496	496
q13	3326	3633	3027	3027
q14	293	293	264	264
q15	q16	669	673	616	616
q17	7804	7054	6890	6890
q18	12935	12242	12956	12242
q19	1021	835	841	835
q20	2152	2127	1949	1949
q21	5764	4680	4647	4647
q22	521	451	423	423
Total cold run time: 72985 ms
Total hot run time: 66122 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 151826 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 20efa876dbac76deccca01cf695ffee8cfae17d3, data reload: false

query5	4308	588	464	464
query6	450	206	205	205
query7	4801	455	244	244
query8	326	176	152	152
query9	8781	3212	3210	3210
query10	480	313	253	253
query11	5988	3858	3571	3571
query12	162	91	87	87
query13	1263	476	336	336
query14	6144	3971	3655	3655
query14_1	3463	3461	3436	3436
query15	211	200	185	185
query16	945	460	436	436
query17	866	680	562	562
query18	2424	430	319	319
query19	202	172	133	133
query20	88	84	85	84
query21	215	135	111	111
query22	13030	13009	12813	12813
query23	13620	13122	12521	12521
query23_1	12444	12602	12570	12570
query24	7395	876	483	483
query24_1	508	482	486	482
query25	545	423	370	370
query26	1273	265	142	142
query27	2748	443	284	284
query28	4619	2043	2026	2026
query29	1600	615	459	459
query30	309	232	193	193
query31	1013	954	806	806
query32	158	100	95	95
query33	535	311	251	251
query34	919	884	508	508
query35	752	751	653	653
query36	808	813	719	719
query37	128	105	83	83
query38	1782	1729	1642	1642
query39	811	798	747	747
query39_1	743	728	746	728
query40	223	122	103	103
query41	73	73	70	70
query42	99	90	84	84
query43	353	365	313	313
query44	1411	706	714	706
query45	181	178	205	178
query46	849	978	567	567
query47	3039	2943	2892	2892
query48	295	317	223	223
query49	587	396	289	289
query50	716	287	212	212
query51	10539	10453	10370	10370
query52	79	88	70	70
query53	194	216	152	152
query54	255	196	179	179
query55	76	69	70	69
query56	233	211	209	209
query57	1697	1632	1589	1589
query58	288	270	256	256
query59	2162	2175	2003	2003
query60	283	251	235	235
query61	151	153	145	145
query62	393	350	285	285
query63	194	163	164	163
query64	2755	957	763	763
query65	3356	3270	3318	3270
query66	1800	412	303	303
query67	20180	20263	20051	20051
query68	3003	1019	618	618
query69	384	298	241	241
query70	857	789	791	789
query71	292	242	211	211
query72	2791	2340	2318	2318
query73	548	557	297	297
query74	4657	4542	4346	4346
query75	2350	2293	1915	1915
query76	2326	1032	612	612
query77	355	376	280	280
query78	9729	9722	9093	9093
query79	1025	922	539	539
query80	793	460	359	359
query81	562	322	275	275
query82	756	139	105	105
query83	293	200	186	186
query84	320	117	101	101
query85	968	433	373	373
query86	369	234	233	233
query87	1984	1939	1819	1819
query88	3810	2773	2768	2768
query89	337	286	259	259
query90	1711	177	175	175
query91	168	161	133	133
query92	96	88	91	88
query93	1065	1029	583	583
query94	509	315	289	289
query95	577	406	302	302
query96	705	519	240	240
query97	2445	2424	2309	2309
query98	159	156	147	147
query99	766	758	642	642
Total cold run time: 235802 ms
Total hot run time: 151826 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.10	0.05	0.05
query3	0.26	0.09	0.08
query4	1.61	0.10	0.09
query5	0.24	0.24	0.25
query6	1.18	0.68	0.67
query7	0.03	0.01	0.01
query8	0.05	0.04	0.04
query9	0.41	0.35	0.35
query10	0.59	0.59	0.58
query11	0.20	0.14	0.13
query12	0.18	0.15	0.15
query13	0.49	0.49	0.51
query14	1.06	1.02	1.04
query15	0.63	0.61	0.60
query16	0.35	0.35	0.36
query17	1.11	1.18	1.13
query18	0.21	0.18	0.19
query19	2.07	2.01	2.07
query20	0.02	0.01	0.01
query21	15.48	0.20	0.14
query22	4.83	0.05	0.05
query23	16.30	0.32	0.13
query24	2.78	0.58	0.40
query25	0.11	0.05	0.05
query26	1.02	0.21	0.14
query27	0.05	0.05	0.03
query28	4.17	0.77	0.37
query29	12.61	4.21	3.24
query30	0.28	0.14	0.10
query31	2.78	0.56	0.32
query32	3.22	0.61	0.51
query33	3.26	3.14	3.27
query34	15.39	4.02	3.43
query35	3.35	3.36	3.38
query36	0.55	0.48	0.46
query37	0.09	0.06	0.06
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.14
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: 97.49 s
Total hot run time: 24.41 s

@924060929 924060929 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.

Normal database listing filters remote names before local-name mapping. HMS create/rename events previously bypassed that filter when updating FE caches. This PR shares the existing predicate with event registration.

Independent static review of all three changed files and the parser, driver, catalog routing, cache publication, and related tests found no actionable P0/P1/P2 regression. Exclude precedence, system-database exemptions, rename cleanup, and allowed registration remain intact. APPROVE within the FE scope; no FE/BE protocol changes are involved.

No builds or tests were run. The supplied current-head snapshot reports successful P0 checks, compilation and FE UT, but check_coverage_fe failed. Required-check rules are unknown; this approval does not establish merge readiness.

Automated FE-focused static review (gpt-6.1-sol, high). No build or tests were run.

@morningman
morningman merged commit bc5f8cd into apache:master Nov 5, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants