Skip to content

[fix](fe) Make newly created external catalog table immediately visible in cache#63863

Open
heguanhui wants to merge 1 commit into
apache:masterfrom
heguanhui:fix/external-catalog-create-table-cache-visibility
Open

[fix](fe) Make newly created external catalog table immediately visible in cache#63863
heguanhui wants to merge 1 commit into
apache:masterfrom
heguanhui:fix/external-catalog-create-table-cache-visibility

Conversation

@heguanhui
Copy link
Copy Markdown
Contributor

Summary

When creating a table in an external catalog (Iceberg/HMS/Paimon/MaxCompute) via CREATE TABLE, the new table is not immediately visible in the internal meta cache. The afterCreateTable() implementations only call resetMetaCacheNames() which clears the namesCache but does not populate the metaObjCache. As a result, operations like SHOW CREATE TABLE fail with "table does not exist" until a manual REFRESH CATALOG is executed.

The same issue exists in rename table scenarios (IcebergMetadataOps.afterRenameTable and RefreshManager.replayRefreshTable rename branch) where only resetMetaCacheNames is called for the new table name.

Root Cause

  • afterCreateTable() in all 4 external catalog implementations (HiveMetadataOps, IcebergMetadataOps, PaimonMetadataOps, MaxComputeMetadataOps) only calls db.resetMetaCacheNames(), which clears the table name list cache but does NOT load the new table object into metaObjCache
  • When subsequent operations call getTableNullable()metaCache.getMetaObj(), the table object is not found → returns null → reports table does not exist
  • The HMS event processor (MetastoreEventsProcessor) already handles this correctly via registerExternalTableFromEvent() which calls buildTableForInit(checkExists=false) + metaCache.updateCache(), but enable_hms_events_incremental_sync defaults to false

Fix

  • Added registerTableFromCreate(String tblName) method to ExternalDatabase that builds the table object with checkExists=false and calls metaCache.updateCache() to populate both namesCache and metaObjCache
  • Called registerTableFromCreate in ExternalCatalog.createTable(), replayCreateTable(), and renameTable()
  • Fixed RefreshManager.replayRefreshTable() rename branch: replaced resetMetaCacheNames() with registerTableFromCreate(newName)
  • Fixed IcebergMetadataOps.afterRenameTable(): replaced resetMetaCacheNames() with registerTableFromCreate(newName)

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary: After CREATE TABLE in external catalogs (Iceberg/HMS/Paimon/MaxCompute), the new table is not visible in cache. Users must manually run REFRESH CATALOG before they can use the newly created table. The same issue affects rename table operations. This PR makes newly created/renamed tables immediately visible by proactively loading them into the meta cache.

Release note

Newly created or renamed external catalog tables (Iceberg/HMS/Paimon/MaxCompute) are now immediately visible without requiring a manual REFRESH CATALOG.

Check List (For Author)

  • Test: Unit Test + Regression test
    • FE unit test: ExternalDatabaseRegisterTableTest (6 cases covering visibility, namesCache update, idempotency, multi-table, replay, isolation)
    • Regression test: external_table_p0 (Iceberg/Hive/Paimon) and external_table_p2 (MaxCompute)
  • Behavior changed: No (fix only - previously broken scenario now works)
  • Does this need documentation: No

…le in cache

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: When creating a table in an external catalog (Iceberg/HMS/Paimon/MaxCompute) via CREATE TABLE, the new table is not immediately visible in the internal meta cache. The afterCreateTable() implementations only call resetMetaCacheNames() which clears the namesCache but does not populate the metaObjCache. As a result, operations like SHOW CREATE TABLE fail with "table does not exist" until a manual REFRESH CATALOG is executed. The same issue exists in rename table scenarios (IcebergMetadataOps.afterRenameTable and RefreshManager.replayRefreshTable rename branch) where only resetMetaCacheNames is called for the new table name.

### Release note

Newly created or renamed external catalog tables (Iceberg/HMS/Paimon/MaxCompute) are now immediately visible without requiring a manual REFRESH CATALOG.

### Check List (For Author)

- Test: Unit Test + Regression test
    - FE unit test: ExternalDatabaseRegisterTableTest (6 cases covering visibility, namesCache update, idempotency, multi-table, replay, isolation)
    - Regression test: external_table_p0 (Iceberg/Hive/Paimon) and external_table_p2 (MaxCompute)
- Behavior changed: No (fix only - previously broken scenario now works)
- 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?

@heguanhui
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31201 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 1740635d0ef4f69bb677e51beea88f6ee88770ef, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17758	4145	4037	4037
q2	q3	10833	1431	837	837
q4	4701	478	353	353
q5	7826	2287	2068	2068
q6	374	180	137	137
q7	984	791	632	632
q8	9488	1682	1533	1533
q9	6847	4972	5030	4972
q10	6432	2261	1894	1894
q11	443	280	241	241
q12	689	437	299	299
q13	18217	3337	2792	2792
q14	265	252	244	244
q15	q16	815	785	707	707
q17	917	1013	952	952
q18	7053	5769	5535	5535
q19	1213	1262	1030	1030
q20	496	395	254	254
q21	5755	2613	2380	2380
q22	434	360	304	304
Total cold run time: 101540 ms
Total hot run time: 31201 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4419	4345	4437	4345
q2	q3	4540	4921	4324	4324
q4	2088	2207	1398	1398
q5	4457	4306	4906	4306
q6	235	192	137	137
q7	2037	1892	1672	1672
q8	2480	2187	2146	2146
q9	8212	7982	8008	7982
q10	4867	4841	4290	4290
q11	596	408	381	381
q12	810	783	544	544
q13	3264	3710	3087	3087
q14	321	313	287	287
q15	q16	740	749	641	641
q17	1375	1324	1341	1324
q18	7908	7460	6848	6848
q19	1117	1127	1098	1098
q20	2224	2234	1969	1969
q21	5324	4635	4494	4494
q22	530	466	409	409
Total cold run time: 57544 ms
Total hot run time: 51682 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 171183 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 1740635d0ef4f69bb677e51beea88f6ee88770ef, data reload: false

query5	4332	693	521	521
query6	336	225	197	197
query7	4238	591	301	301
query8	339	235	216	216
query9	8806	4094	4062	4062
query10	469	349	299	299
query11	5781	2538	2246	2246
query12	180	129	129	129
query13	1278	614	429	429
query14	6162	5471	5199	5199
query14_1	4529	4507	4472	4472
query15	217	207	186	186
query16	1019	457	443	443
query17	1161	759	612	612
query18	2677	501	368	368
query19	220	209	172	172
query20	154	144	141	141
query21	220	142	122	122
query22	13738	13511	13373	13373
query23	17417	16558	16157	16157
query23_1	16288	16361	16261	16261
query24	7581	1769	1335	1335
query24_1	1336	1326	1329	1326
query25	583	496	447	447
query26	1315	341	176	176
query27	2645	585	346	346
query28	4449	2021	2000	2000
query29	1011	664	505	505
query30	310	240	202	202
query31	1128	1086	972	972
query32	94	79	77	77
query33	547	363	311	311
query34	1196	1133	666	666
query35	785	805	704	704
query36	1409	1450	1279	1279
query37	160	113	99	99
query38	3185	3149	3066	3066
query39	930	951	900	900
query39_1	882	887	866	866
query40	228	143	132	132
query41	66	63	62	62
query42	114	110	118	110
query43	336	330	301	301
query44	
query45	224	208	194	194
query46	1103	1196	718	718
query47	2312	2358	2250	2250
query48	402	416	311	311
query49	660	494	386	386
query50	959	365	262	262
query51	4449	4379	4299	4299
query52	107	114	96	96
query53	258	288	211	211
query54	314	271	263	263
query55	96	94	84	84
query56	315	298	310	298
query57	1479	1439	1394	1394
query58	296	263	270	263
query59	1679	1672	1478	1478
query60	325	322	314	314
query61	206	158	165	158
query62	705	668	593	593
query63	260	210	213	210
query64	2419	811	632	632
query65	
query66	1673	488	383	383
query67	29553	29844	28951	28951
query68	
query69	470	347	304	304
query70	1042	1043	961	961
query71	322	279	277	277
query72	3075	2706	2376	2376
query73	838	803	447	447
query74	5175	5004	4798	4798
query75	2731	2612	2276	2276
query76	2292	1192	823	823
query77	410	428	337	337
query78	12355	12451	11851	11851
query79	1461	1076	750	750
query80	1315	538	465	465
query81	503	280	241	241
query82	1363	165	122	122
query83	358	288	252	252
query84	254	149	109	109
query85	935	545	456	456
query86	428	375	333	333
query87	3432	3371	3257	3257
query88	3684	2758	2728	2728
query89	454	393	342	342
query90	1810	190	190	190
query91	182	173	142	142
query92	82	75	71	71
query93	1585	1400	875	875
query94	675	366	318	318
query95	685	474	354	354
query96	1067	797	355	355
query97	2745	2734	2602	2602
query98	234	232	226	226
query99	1168	1164	1039	1039
Total cold run time: 255858 ms
Total hot run time: 171183 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 50.00% (12/24) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/24) 🎉
Increment coverage report
Complete coverage report

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.

2 participants