Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement](external catalog) Added status reset when jdbc name mapping is abnormal #33971

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

zy-kkk
Copy link
Member

@zy-kkk zy-kkk commented Apr 22, 2024

Proposed changes

Issue Number: close #xxx

This PR introduces several important improvements aimed at enhancing the robustness, maintainability, and error handling efficiency of database connectivity and data retrieval processes. Here are the main optimization points:

  1. Code Abstraction and Reuse:

    • Introduced getRequiredMapping method to centralize the common logic for retrieving database, table, and column names. This change reduces repetitive code across multiple functions, making the overall code structure more compact and consistent.
  2. Unified Error Handling:

    • In the new getRequiredMapping method, missing mappings are handled uniformly. If a mapping is not found, the corresponding loading function is automatically triggered, and an exception is thrown if data remains missing. This approach simplifies error management and enhances code readability and maintainability.
  3. Enhanced Exception Safety:

    • Added more rigorous checks at all critical data access points to ensure timely feedback and handling of exceptions when data is not successfully loaded, rather than just relying on the default behavior of data structures.
  4. Improved Robustness:

    • Used ConcurrentHashMap and AtomicBoolean to ensure data consistency and thread safety in a multi-threaded environment. Optimized data checks and exception handling logic reduce potential issues caused by concurrent modifications.
  5. Improved Logging:

    • Enhanced detailed logging at all points of data loading and exception handling. This not only helps in monitoring runtime states but also facilitates troubleshooting and subsequent debugging.

Further comments

If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...

@doris-robot
Copy link

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

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@zy-kkk
Copy link
Member Author

zy-kkk commented Apr 22, 2024

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17617	4355	4262	4262
q2	2008	188	188	188
q3	10434	1227	1115	1115
q4	10198	942	751	751
q5	7527	2717	2673	2673
q6	218	133	137	133
q7	1030	610	577	577
q8	9222	2084	2075	2075
q9	7526	6619	6606	6606
q10	8652	3545	3544	3544
q11	465	235	226	226
q12	413	217	214	214
q13	17767	2975	2957	2957
q14	269	236	227	227
q15	525	497	490	490
q16	516	400	387	387
q17	965	709	689	689
q18	7488	6827	6619	6619
q19	5328	1550	1474	1474
q20	659	306	302	302
q21	3495	2726	2874	2726
q22	370	302	311	302
Total cold run time: 112692 ms
Total hot run time: 38537 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4318	4215	4258	4215
q2	371	267	278	267
q3	3039	2715	2736	2715
q4	1854	1613	1627	1613
q5	5354	5312	5296	5296
q6	209	120	121	120
q7	2215	1856	1894	1856
q8	3207	3390	3325	3325
q9	8675	8602	8662	8602
q10	4056	3890	3971	3890
q11	612	490	497	490
q12	795	626	646	626
q13	16224	3240	3172	3172
q14	330	301	278	278
q15	525	486	496	486
q16	524	435	450	435
q17	1830	1586	1529	1529
q18	8145	8005	7798	7798
q19	1740	1603	1560	1560
q20	1955	1810	1878	1810
q21	5181	5123	4887	4887
q22	569	478	475	475
Total cold run time: 71728 ms
Total hot run time: 55445 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 185126 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 206cf0014c4f3cf28e87f798f5673d6bd68640cd, data reload: false

query1	929	374	362	362
query2	6206	2654	2349	2349
query3	6662	215	209	209
query4	22796	21357	21112	21112
query5	4179	405	407	405
query6	262	189	177	177
query7	4590	287	292	287
query8	257	197	189	189
query9	8475	2293	2258	2258
query10	436	247	277	247
query11	14642	14091	14241	14091
query12	139	93	90	90
query13	1637	376	372	372
query14	9299	7839	7247	7247
query15	229	180	178	178
query16	7860	275	289	275
query17	1871	556	554	554
query18	1951	268	269	268
query19	196	146	151	146
query20	99	87	87	87
query21	206	127	132	127
query22	4977	4785	4797	4785
query23	33825	33117	33312	33117
query24	6878	3059	3076	3059
query25	602	385	410	385
query26	698	164	160	160
query27	2181	355	386	355
query28	3833	2054	2036	2036
query29	859	621	610	610
query30	236	177	172	172
query31	993	735	757	735
query32	92	55	56	55
query33	516	245	254	245
query34	928	504	514	504
query35	816	701	711	701
query36	1042	951	889	889
query37	127	70	71	70
query38	3480	3399	3340	3340
query39	1666	1597	1587	1587
query40	173	130	138	130
query41	47	42	44	42
query42	108	99	102	99
query43	588	525	538	525
query44	1119	757	744	744
query45	288	281	280	280
query46	1107	774	725	725
query47	2030	1939	1946	1939
query48	402	299	300	299
query49	751	387	395	387
query50	786	407	406	406
query51	6864	6821	6763	6763
query52	110	91	96	91
query53	356	283	293	283
query54	263	238	237	237
query55	81	76	80	76
query56	250	235	234	234
query57	1305	1181	1164	1164
query58	222	214	206	206
query59	3525	3441	3176	3176
query60	256	229	239	229
query61	88	85	103	85
query62	539	420	421	420
query63	307	277	284	277
query64	4492	4146	3962	3962
query65	3102	2992	3051	2992
query66	742	318	320	318
query67	15302	15398	15135	15135
query68	5177	532	539	532
query69	502	305	299	299
query70	1166	1184	1172	1172
query71	1390	1265	1268	1265
query72	6378	2588	2453	2453
query73	740	322	319	319
query74	6874	6416	6501	6416
query75	3334	2642	2602	2602
query76	2938	1018	967	967
query77	593	268	265	265
query78	10882	10335	10172	10172
query79	6315	537	527	527
query80	1747	435	433	433
query81	522	252	244	244
query82	1318	97	98	97
query83	323	170	167	167
query84	261	86	83	83
query85	1517	270	261	261
query86	491	282	288	282
query87	3480	3285	3239	3239
query88	4966	2399	2399	2399
query89	492	375	369	369
query90	1943	178	181	178
query91	126	96	98	96
query92	63	50	55	50
query93	5780	501	499	499
query94	1096	241	176	176
query95	387	298	294	294
query96	619	265	263	263
query97	3092	2928	2906	2906
query98	231	214	227	214
query99	1165	858	828	828
Total cold run time: 277781 ms
Total hot run time: 185126 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.04
query2	0.09	0.04	0.04
query3	0.23	0.05	0.05
query4	1.69	0.08	0.09
query5	0.50	0.48	0.51
query6	1.38	0.72	0.72
query7	0.02	0.01	0.02
query8	0.05	0.04	0.04
query9	0.55	0.49	0.49
query10	0.54	0.57	0.54
query11	0.16	0.12	0.12
query12	0.14	0.12	0.12
query13	0.60	0.57	0.58
query14	0.76	0.77	0.78
query15	0.83	0.81	0.80
query16	0.36	0.35	0.36
query17	1.02	1.02	0.93
query18	0.23	0.24	0.22
query19	1.79	1.70	1.65
query20	0.01	0.01	0.01
query21	15.40	0.65	0.65
query22	4.23	7.37	1.58
query23	18.28	1.37	1.24
query24	1.33	0.44	0.24
query25	0.15	0.08	0.09
query26	0.27	0.17	0.15
query27	0.07	0.08	0.09
query28	13.33	0.99	1.00
query29	12.65	3.25	3.24
query30	0.26	0.06	0.05
query31	2.84	0.38	0.36
query32	3.27	0.46	0.46
query33	2.82	2.86	2.85
query34	17.12	4.48	4.47
query35	4.42	4.48	4.51
query36	0.65	0.46	0.46
query37	0.20	0.15	0.15
query38	0.16	0.15	0.15
query39	0.04	0.03	0.04
query40	0.17	0.14	0.14
query41	0.10	0.06	0.05
query42	0.05	0.04	0.04
query43	0.04	0.04	0.04
Total cold run time: 108.84 s
Total hot run time: 30 s

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

Change to log level to warn

loadColumnNamesIfNeeded(localDbName, localTableName);
}
return localColumnToRemoteColumn.get(remoteDbName).get(remoteTableName);
if (columnMap.isEmpty()) {
LOG.error("No remote column found for localTableName: {}. Please refresh this catalog.", localTableName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.error("No remote column found for localTableName: {}. Please refresh this catalog.", localTableName);
LOG.warn("No remote column found for localTableName: {}. Please refresh this catalog.", localTableName);

loadDatabaseNames();
} catch (Exception e) {
dbNamesLoaded.set(false); // Reset on failure
LOG.error("Error loading database names", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.error("Error loading database names", e);
LOG.warn("Error loading database names", e);

@zy-kkk
Copy link
Member Author

zy-kkk commented Apr 25, 2024

run buildall

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

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

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Apr 25, 2024
Copy link
Contributor

PR approved by anyone and no changes requested.

@zy-kkk
Copy link
Member Author

zy-kkk commented Apr 25, 2024

run cloud_p1

@zy-kkk
Copy link
Member Author

zy-kkk commented Apr 26, 2024

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17626	4654	4370	4370
q2	2509	216	197	197
q3	10892	1302	1239	1239
q4	10901	775	754	754
q5	8210	2794	2737	2737
q6	217	132	134	132
q7	1055	616	605	605
q8	9663	2132	2093	2093
q9	9252	6749	6619	6619
q10	8740	3727	3711	3711
q11	456	243	235	235
q12	429	220	223	220
q13	18573	2941	2972	2941
q14	282	223	242	223
q15	514	478	481	478
q16	516	380	384	380
q17	951	640	730	640
q18	7953	7527	7396	7396
q19	5199	1547	1527	1527
q20	649	325	301	301
q21	4987	3970	4050	3970
q22	328	275	272	272
Total cold run time: 119902 ms
Total hot run time: 41040 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4378	4252	4230	4230
q2	376	264	276	264
q3	3022	2786	2772	2772
q4	1892	1571	1554	1554
q5	5347	5318	5294	5294
q6	209	123	127	123
q7	2246	1839	1849	1839
q8	3259	3374	3357	3357
q9	8613	8638	8607	8607
q10	3908	3738	3718	3718
q11	589	499	485	485
q12	744	595	594	594
q13	16339	2957	2942	2942
q14	302	282	264	264
q15	522	462	476	462
q16	478	421	420	420
q17	1755	1456	1466	1456
q18	7621	7505	7394	7394
q19	1655	1585	1497	1497
q20	1968	1759	1772	1759
q21	10298	4671	4798	4671
q22	581	502	508	502
Total cold run time: 76102 ms
Total hot run time: 54204 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 186192 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 56850a62046ee9c07367b07e09bef6fa7e8b8812, data reload: false

query1	913	380	369	369
query2	6447	2448	2382	2382
query3	6657	199	202	199
query4	26355	21329	21212	21212
query5	4159	400	427	400
query6	277	190	195	190
query7	4586	288	285	285
query8	249	195	187	187
query9	8404	2358	2301	2301
query10	427	245	248	245
query11	14774	14213	14325	14213
query12	131	89	90	89
query13	1666	363	366	363
query14	9135	6662	7793	6662
query15	259	173	180	173
query16	8147	258	257	257
query17	1849	574	551	551
query18	2115	282	284	282
query19	220	151	166	151
query20	94	92	88	88
query21	205	130	125	125
query22	5125	4915	4821	4821
query23	33909	33302	33209	33209
query24	11845	3042	2974	2974
query25	697	387	383	383
query26	1855	153	148	148
query27	3125	314	323	314
query28	7546	1997	1979	1979
query29	1057	623	600	600
query30	301	150	151	150
query31	951	759	725	725
query32	95	55	56	55
query33	754	255	252	252
query34	1088	471	472	471
query35	829	712	692	692
query36	1067	923	921	921
query37	280	70	68	68
query38	3355	3253	3215	3215
query39	1597	1529	1513	1513
query40	276	126	125	125
query41	45	42	40	40
query42	106	161	92	92
query43	577	563	513	513
query44	1220	717	725	717
query45	285	260	254	254
query46	1084	713	730	713
query47	1940	1855	1864	1855
query48	375	297	294	294
query49	1182	403	385	385
query50	777	384	374	374
query51	6875	6769	6706	6706
query52	101	89	94	89
query53	344	283	276	276
query54	310	250	227	227
query55	77	71	70	70
query56	234	224	235	224
query57	1222	1134	1141	1134
query58	224	195	193	193
query59	3431	3371	3218	3218
query60	249	238	232	232
query61	93	88	90	88
query62	640	444	438	438
query63	306	281	269	269
query64	9420	7183	7109	7109
query65	3103	3065	3077	3065
query66	1373	338	325	325
query67	15594	14900	14887	14887
query68	9226	549	557	549
query69	546	298	307	298
query70	1372	1042	1110	1042
query71	503	267	270	267
query72	8244	2608	2442	2442
query73	1597	315	328	315
query74	6866	6474	6338	6338
query75	4309	2630	2668	2630
query76	5616	1054	1008	1008
query77	628	266	261	261
query78	11061	10272	10351	10272
query79	12113	513	510	510
query80	1736	432	419	419
query81	503	223	217	217
query82	236	92	89	89
query83	203	159	161	159
query84	259	85	83	83
query85	1003	266	265	265
query86	339	287	295	287
query87	3531	3401	3350	3350
query88	5206	2322	2326	2322
query89	526	379	360	360
query90	2076	175	179	175
query91	123	97	96	96
query92	61	49	47	47
query93	6683	514	493	493
query94	1324	181	172	172
query95	394	293	300	293
query96	610	270	265	265
query97	3146	2960	3003	2960
query98	238	226	212	212
query99	1225	883	870	870
Total cold run time: 315511 ms
Total hot run time: 186192 ms

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@kaka11chen kaka11chen left a comment

Choose a reason for hiding this comment

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

LGTM

@zy-kkk zy-kkk merged commit 75cb520 into apache:master Apr 27, 2024
26 of 30 checks passed
@zy-kkk zy-kkk deleted the jdbc_mapping_opt branch April 27, 2024 07:40
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.3-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants