Skip to content

Conversation

@morningman
Copy link
Contributor

@morningman morningman commented Jul 9, 2025

What problem does this PR solve?

Problem Summary:

  1. Refactor Refresh Interface and Logic

    • Unified the RefreshManager interface so that both the old and new statements can use the same method.

    • Modified the edit log for REFRESH TABLE and REFRESH DATABASE to store database/table names instead of IDs, enabling the replayer to correctly retrieve the corresponding objects.

  2. Optimize Metadata Refresh After Create/Drop/Truncate Table

    • Previously, Doris would refresh the entire database and its related cache after creating, dropping, or truncating a table.

    • This was inefficient and unnecessary—now the logic only refreshes the cache of the affected table.

  3. Fix a Bug in ExternalDatabase

    Fixed an issue where the lowerCaseToTableName map in ExternalDatabase was not cleared during refresh operations, potentially leading to stale or incorrect data remaining in the map.

Release note

None

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
  • Behavior changed:

    • No.
    • Yes.
  • 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

@hello-stephen
Copy link
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
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17576	5243	5065	5065
q2	1928	293	187	187
q3	10282	1269	697	697
q4	10235	991	526	526
q5	7515	2388	2304	2304
q6	175	156	126	126
q7	901	743	598	598
q8	9315	1468	1035	1035
q9	6730	5088	5115	5088
q10	6865	2381	1954	1954
q11	490	280	281	280
q12	332	346	204	204
q13	17779	3745	3052	3052
q14	242	233	208	208
q15	555	473	471	471
q16	422	418	361	361
q17	608	842	378	378
q18	7401	7004	7072	7004
q19	1217	943	554	554
q20	328	322	217	217
q21	3638	3154	2284	2284
q22	348	321	297	297
Total cold run time: 104882 ms
Total hot run time: 32890 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5048	5039	5061	5039
q2	238	320	221	221
q3	2146	2658	2299	2299
q4	1347	1803	1345	1345
q5	4208	4121	4445	4121
q6	217	175	135	135
q7	2027	1887	1816	1816
q8	2658	2570	2539	2539
q9	7410	7303	7225	7225
q10	3091	3252	2871	2871
q11	560	509	487	487
q12	697	808	696	696
q13	3555	3948	3381	3381
q14	285	319	283	283
q15	512	478	474	474
q16	445	518	453	453
q17	1145	1528	1406	1406
q18	8028	7386	7758	7386
q19	817	822	889	822
q20	1961	2091	1885	1885
q21	4756	4315	4313	4313
q22	625	562	534	534
Total cold run time: 51776 ms
Total hot run time: 49731 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 186385 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 abeb0a83e628d6e6c95cebcd63c6647809e99a0b, data reload: false

query1	1044	377	399	377
query2	6498	1752	1747	1747
query3	7210	211	226	211
query4	26550	23547	23001	23001
query5	4406	585	430	430
query6	301	211	208	208
query7	4625	484	287	287
query8	280	218	218	218
query9	8620	2634	2632	2632
query10	503	330	266	266
query11	15766	15001	14772	14772
query12	148	104	108	104
query13	1666	535	409	409
query14	8973	5935	6069	5935
query15	208	199	173	173
query16	7618	436	266	266
query17	1317	729	592	592
query18	2028	410	339	339
query19	190	185	153	153
query20	119	110	113	110
query21	210	115	98	98
query22	4204	4236	4003	4003
query23	33824	33214	32952	32952
query24	8414	2348	2379	2348
query25	539	463	392	392
query26	1068	264	143	143
query27	2768	504	347	347
query28	4267	2109	2096	2096
query29	716	556	421	421
query30	283	221	189	189
query31	936	794	794	794
query32	73	59	58	58
query33	526	330	272	272
query34	792	830	512	512
query35	579	643	570	570
query36	917	1017	856	856
query37	111	94	76	76
query38	4200	4168	4038	4038
query39	1518	1421	1412	1412
query40	208	116	101	101
query41	54	53	49	49
query42	123	110	108	108
query43	517	516	504	504
query44	1290	811	808	808
query45	170	164	164	164
query46	881	1017	628	628
query47	1753	1777	1764	1764
query48	369	408	308	308
query49	719	486	362	362
query50	628	690	414	414
query51	5422	5596	5403	5403
query52	105	101	97	97
query53	225	254	187	187
query54	569	568	504	504
query55	86	81	79	79
query56	299	298	285	285
query57	1183	1177	1122	1122
query58	261	245	251	245
query59	2667	2787	2692	2692
query60	323	314	311	311
query61	125	150	122	122
query62	808	718	668	668
query63	220	183	182	182
query64	3977	1192	828	828
query65	4267	4175	4222	4175
query66	971	413	309	309
query67	15686	15735	15357	15357
query68	7980	875	524	524
query69	507	366	273	273
query70	1172	1114	1118	1114
query71	454	346	298	298
query72	5536	4617	4723	4617
query73	667	597	343	343
query74	9123	8772	8831	8772
query75	3820	3180	2680	2680
query76	3523	1123	714	714
query77	787	438	297	297
query78	10852	10974	10225	10225
query79	2085	819	586	586
query80	590	512	441	441
query81	462	254	221	221
query82	423	133	100	100
query83	256	252	243	243
query84	244	105	92	92
query85	860	345	301	301
query86	337	294	292	292
query87	4387	4375	4307	4307
query88	3687	2282	2263	2263
query89	383	316	287	287
query90	1920	201	199	199
query91	134	140	111	111
query92	73	60	56	56
query93	1516	914	583	583
query94	674	317	197	197
query95	371	282	293	282
query96	489	566	279	279
query97	2655	2742	2600	2600
query98	239	213	205	205
query99	1434	1419	1300	1300
Total cold run time: 275561 ms
Total hot run time: 186385 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 29.83 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit abeb0a83e628d6e6c95cebcd63c6647809e99a0b, data reload: false

query1	0.04	0.04	0.04
query2	0.08	0.05	0.04
query3	0.24	0.08	0.07
query4	1.62	0.11	0.11
query5	0.44	0.42	0.44
query6	1.21	0.66	0.65
query7	0.03	0.02	0.02
query8	0.04	0.04	0.04
query9	0.60	0.52	0.51
query10	0.56	0.57	0.57
query11	0.16	0.11	0.11
query12	0.14	0.13	0.11
query13	0.62	0.60	0.61
query14	0.78	0.83	0.80
query15	0.89	0.87	0.88
query16	0.38	0.38	0.38
query17	1.06	1.08	1.06
query18	0.23	0.21	0.21
query19	1.94	1.92	1.83
query20	0.02	0.01	0.02
query21	15.38	0.90	0.53
query22	0.76	1.19	0.65
query23	14.97	1.37	0.66
query24	7.09	1.32	1.05
query25	0.46	0.27	0.10
query26	0.64	0.16	0.15
query27	0.07	0.05	0.05
query28	9.62	0.90	0.45
query29	12.54	4.07	3.30
query30	0.25	0.09	0.07
query31	2.86	0.58	0.39
query32	3.25	0.57	0.47
query33	3.08	3.17	3.14
query34	16.08	5.36	4.76
query35	4.78	4.81	4.86
query36	0.69	0.50	0.48
query37	0.08	0.06	0.07
query38	0.05	0.03	0.04
query39	0.03	0.02	0.03
query40	0.16	0.15	0.14
query41	0.08	0.03	0.02
query42	0.03	0.03	0.02
query43	0.03	0.04	0.03
Total cold run time: 104.06 s
Total hot run time: 29.83 s

@morningman morningman changed the title [fix](catalog) add some log to debug [fix](catalog) fix refresh logic Jul 11, 2025
@morningman morningman requested a review from Copilot July 11, 2025 04:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the refresh logic across multiple layers (DDL executor, Nereids commands, metadata operations, and the log/persistence layer) to use new handleRefresh* APIs and standardized ExternalObjectLog factories.

  • Unify refresh calls to RefreshManager.handleRefresh* with explicit parameters instead of passing statement objects.
  • Update ExternalObjectLog and CatalogLog to use static factory methods and remove direct setters.
  • Adjust metadata operations (IcebergMetadataOps, HiveMetadataOps, ExternalCatalog, etc.) to match the new refresh signatures and log behavior.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergExternalTableBranchAndTagTest.java Updated Mockito stub to match new refreshTableInternal signature.
fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java Replaced statement-based refresh with parameterized handleRefreshTable/handleRefreshDb calls.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/refresh/RefreshTableCommand.java Switched from refreshTable to handleRefreshTable.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/refresh/RefreshDatabaseCommand.java Removed inline handleRefreshDb and replaced with manager call.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/refresh/RefreshCatalogCommand.java Replaced inline catalog refresh with manager call.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/BaseExternalTableInsertExecutor.java Updated to call handleRefreshTable instead of refreshTable.
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java Streamlined setUnInitialized calls and added logging.
fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java Streamlined setUnInitialized calls and added logging.
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalObjectLog.java Added private constructor and factory methods for log creation.
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java Removed boolean parameter from setUnInitialized and cleared state.
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java Removed internal invalidCacheInInit flag and adjusted cache initialization.
fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogLog.java Added static factory for refresh catalog logs.
fe/fe-core/src/main/java/org/apache/doris/catalog/RefreshManager.java Refactored all handleRefresh* methods to use parameter lists and factory logs.
Comments suppressed due to low confidence (2)

fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java:240

  • The literal false passed to handleRefreshTable ignores any IF EXISTS flag in the RefreshTableStmt. Consider using refreshTableStmt.isIgnoreIfNotExists() (or the appropriate method) to propagate the user's intent.
                    refreshTableStmt.getTblName(), false);

fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalObjectLog.java:61

  • Making the no-args constructor private will break GSON deserialization in read(). You should provide a public or package-private no-args constructor for proper deserialization.
    private ExternalObjectLog() {

}
db.get().setUnInitialized();
}
LOG.info("after drop table {}.{}.{}, is db exists: {}",
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] The log message reads "is db exists" which is grammatically awkward. Consider rephrasing to something like "db exists: {}" or "does db exist: {}".

Suggested change
LOG.info("after drop table {}.{}.{}, is db exists: {}",
LOG.info("after drop table {}.{}.{}, db exists: {}",

Copilot uses AI. Check for mistakes.
@morningman
Copy link
Contributor Author

run buildall

morningman added a commit to morningman/doris that referenced this pull request Jul 11, 2025
morningman added a commit to morningman/doris that referenced this pull request Jul 11, 2025
@morningman morningman marked this pull request as ready for review July 11, 2025 04:27
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17554	5174	5090	5090
q2	1924	287	201	201
q3	10535	1338	734	734
q4	10313	1033	522	522
q5	9021	2424	2414	2414
q6	212	158	128	128
q7	929	762	615	615
q8	9338	1293	1110	1110
q9	7448	5100	5115	5100
q10	6902	2376	1970	1970
q11	495	290	276	276
q12	343	359	220	220
q13	17765	3625	3036	3036
q14	225	239	212	212
q15	550	486	478	478
q16	432	426	375	375
q17	607	887	379	379
q18	7762	7291	7102	7102
q19	1257	953	541	541
q20	353	363	222	222
q21	4098	3256	2388	2388
q22	365	314	307	307
Total cold run time: 108428 ms
Total hot run time: 33420 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5135	5075	5084	5075
q2	251	326	228	228
q3	2173	2697	2300	2300
q4	1378	1788	1331	1331
q5	4236	4568	4579	4568
q6	217	170	122	122
q7	2030	1951	1825	1825
q8	2667	2623	2588	2588
q9	7376	7210	7544	7210
q10	3051	3340	2878	2878
q11	565	515	491	491
q12	663	764	615	615
q13	3601	4015	3327	3327
q14	308	318	285	285
q15	538	478	472	472
q16	488	497	437	437
q17	1172	1651	1361	1361
q18	8091	7798	7677	7677
q19	819	797	867	797
q20	2028	2083	1926	1926
q21	5070	4576	4517	4517
q22	635	592	552	552
Total cold run time: 52492 ms
Total hot run time: 50582 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 188190 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 58326421b7a91d384f17b4f2bb2aef154e959ee6, data reload: false

query1	1005	383	382	382
query2	6512	1669	1679	1669
query3	6736	218	211	211
query4	26265	23711	23864	23711
query5	4328	587	429	429
query6	305	197	188	188
query7	4611	493	292	292
query8	278	220	209	209
query9	8621	2619	2629	2619
query10	455	317	276	276
query11	15221	15000	14818	14818
query12	154	107	99	99
query13	1642	515	418	418
query14	8627	5807	5740	5740
query15	206	195	194	194
query16	7121	611	487	487
query17	916	706	585	585
query18	1965	404	307	307
query19	194	196	159	159
query20	124	113	114	113
query21	219	124	108	108
query22	4176	4224	4522	4224
query23	34771	34029	33847	33847
query24	8446	2378	2400	2378
query25	560	480	417	417
query26	1237	263	157	157
query27	2768	514	343	343
query28	4317	2131	2113	2113
query29	812	602	455	455
query30	285	218	184	184
query31	917	868	752	752
query32	71	66	64	64
query33	562	382	323	323
query34	800	890	509	509
query35	768	842	725	725
query36	969	986	869	869
query37	112	97	75	75
query38	4119	4158	4050	4050
query39	1458	1403	1433	1403
query40	216	114	107	107
query41	54	54	50	50
query42	123	101	108	101
query43	488	499	481	481
query44	1337	818	815	815
query45	175	163	159	159
query46	827	1014	628	628
query47	1799	1822	1754	1754
query48	372	413	310	310
query49	772	478	388	388
query50	634	688	414	414
query51	5610	5554	5456	5456
query52	109	103	95	95
query53	218	250	187	187
query54	568	564	485	485
query55	82	81	79	79
query56	312	292	281	281
query57	1220	1189	1095	1095
query58	266	250	254	250
query59	2642	2618	2543	2543
query60	325	326	306	306
query61	128	121	122	121
query62	794	736	681	681
query63	225	190	185	185
query64	4342	1017	692	692
query65	4262	4195	4194	4194
query66	1127	401	305	305
query67	15941	16158	15675	15675
query68	8609	884	529	529
query69	484	321	279	279
query70	1244	1184	1161	1161
query71	499	335	299	299
query72	5432	4763	4905	4763
query73	745	629	344	344
query74	8952	9191	8805	8805
query75	3927	3169	2730	2730
query76	3762	1134	723	723
query77	794	382	289	289
query78	10170	10266	9347	9347
query79	2682	843	576	576
query80	624	516	444	444
query81	482	251	216	216
query82	463	125	96	96
query83	275	243	237	237
query84	287	118	85	85
query85	779	376	325	325
query86	348	325	285	285
query87	4461	4424	4371	4371
query88	3149	2231	2247	2231
query89	404	321	278	278
query90	1926	198	201	198
query91	151	144	112	112
query92	71	61	53	53
query93	1178	973	590	590
query94	680	391	299	299
query95	375	283	289	283
query96	495	574	280	280
query97	2783	2795	2709	2709
query98	226	200	208	200
query99	1449	1405	1314	1314
Total cold run time: 275527 ms
Total hot run time: 188190 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 30.06 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 58326421b7a91d384f17b4f2bb2aef154e959ee6, data reload: false

query1	0.04	0.03	0.03
query2	0.08	0.04	0.04
query3	0.25	0.08	0.08
query4	1.61	0.10	0.11
query5	0.44	0.41	0.43
query6	1.17	0.65	0.66
query7	0.02	0.02	0.01
query8	0.05	0.03	0.04
query9	0.59	0.51	0.52
query10	0.57	0.58	0.58
query11	0.16	0.11	0.11
query12	0.15	0.12	0.12
query13	0.62	0.61	0.60
query14	0.79	0.81	0.81
query15	0.89	0.90	0.87
query16	0.41	0.39	0.40
query17	1.07	1.04	1.08
query18	0.23	0.22	0.21
query19	1.99	1.81	1.87
query20	0.01	0.01	0.01
query21	15.40	0.91	0.55
query22	0.76	1.22	0.67
query23	14.90	1.41	0.67
query24	6.73	1.40	1.22
query25	0.50	0.21	0.15
query26	0.57	0.18	0.14
query27	0.07	0.06	0.05
query28	9.46	0.88	0.44
query29	12.58	4.08	3.36
query30	0.25	0.09	0.07
query31	2.85	0.58	0.39
query32	3.23	0.56	0.47
query33	3.06	3.06	3.17
query34	15.92	5.37	4.79
query35	4.80	4.85	4.82
query36	0.67	0.52	0.48
query37	0.09	0.07	0.07
query38	0.06	0.04	0.04
query39	0.03	0.03	0.02
query40	0.18	0.13	0.12
query41	0.08	0.03	0.02
query42	0.03	0.03	0.02
query43	0.04	0.03	0.03
Total cold run time: 103.4 s
Total hot run time: 30.06 s

morrySnow pushed a commit that referenced this pull request Jul 11, 2025
…ystem. #52561 #52817 #52881 #52989 (#53030)

bp (#52561)(#52817)(#52881)(#52989)

---------

Co-authored-by: Socrates <suyiteng@selectdb.com>
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jul 12, 2025
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@morningman morningman merged commit 218ec17 into apache:master Jul 13, 2025
34 of 37 checks passed
morningman added a commit to morningman/doris that referenced this pull request Jul 28, 2025
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/2.1.11-merged dev/3.0.7-merged dev/3.1.0-merged reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants