Skip to content

[fix](session) Reset session state for COM_RESET_CONNECTION#63884

Open
yujun777 wants to merge 1 commit into
apache:masterfrom
yujun777:fix-reset-connection-session-vars
Open

[fix](session) Reset session state for COM_RESET_CONNECTION#63884
yujun777 wants to merge 1 commit into
apache:masterfrom
yujun777:fix-reset-connection-session-vars

Conversation

@yujun777
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

COM_RESET_CONNECTION only reset the default catalog and catalog database cache, so session-scoped variables such as sql_select_limit could leak into the next logical connection when clients reused the same physical connection.

What is changed?

  • Reset session variables, user variables, prepared statements, running query state, catalog/database state, and returned row count on COM_RESET_CONNECTION.
  • Reapply user-level default query_timeout and insert_timeout after rebuilding SessionVariable.
  • Add a regression test helper that sends COM_RESET_CONNECTION directly through the MySQL protocol.
  • Add a regression case for sql_select_limit = 0 being cleared after reset connection.

Check List

  • FE UT: ConnectContextTest
  • Regression: test_reset_connection_session_variable

COM_RESET_CONNECTION should clear session-scoped state without losing user-level default session settings such as query and insert timeout.

Key changes:

- Reset session variables, user variables, prepared statements, catalog/database state, running query, and return rows on COM_RESET_CONNECTION.

- Reapply user default query_timeout and insert_timeout after rebuilding SessionVariable.

- Add a regression helper to send COM_RESET_CONNECTION directly through the MySQL protocol.

Unit Test:

- ConnectContextTest

- test_reset_connection_session_variable
@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?

@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31506 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 81b02813836a396aeb4ede0f20ebf8aecb9bec19, 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	17604	3947	3959	3947
q2	q3	10748	1450	821	821
q4	4684	485	355	355
q5	7594	2243	2112	2112
q6	318	175	137	137
q7	1023	787	664	664
q8	9368	1761	1721	1721
q9	7203	5043	4986	4986
q10	6446	2285	1874	1874
q11	433	276	245	245
q12	698	431	302	302
q13	18201	3398	2756	2756
q14	264	260	240	240
q15	q16	819	781	712	712
q17	953	931	933	931
q18	6831	5690	5666	5666
q19	1170	1272	1114	1114
q20	519	415	264	264
q21	5639	2572	2357	2357
q22	435	359	302	302
Total cold run time: 100950 ms
Total hot run time: 31506 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	4314	4237	4253	4237
q2	q3	4520	4937	4398	4398
q4	2108	2206	1405	1405
q5	4442	4310	4785	4310
q6	265	202	150	150
q7	2009	1864	1605	1605
q8	2499	2145	2183	2145
q9	7950	7922	7869	7869
q10	4881	4769	4485	4485
q11	573	415	375	375
q12	752	793	543	543
q13	3275	3609	3049	3049
q14	314	328	274	274
q15	q16	770	725	627	627
q17	1371	1334	1335	1334
q18	8016	7467	6903	6903
q19	1134	1088	1123	1088
q20	2234	2203	1947	1947
q21	5306	4565	4450	4450
q22	529	456	426	426
Total cold run time: 57262 ms
Total hot run time: 51620 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 173055 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 81b02813836a396aeb4ede0f20ebf8aecb9bec19, data reload: false

query5	4349	681	528	528
query6	340	219	201	201
query7	4240	593	332	332
query8	337	245	231	231
query9	8806	4092	4060	4060
query10	456	349	308	308
query11	5769	2500	2220	2220
query12	191	134	126	126
query13	1284	642	443	443
query14	6098	5496	5185	5185
query14_1	4519	4554	4470	4470
query15	218	205	187	187
query16	988	445	450	445
query17	1133	722	597	597
query18	2521	484	347	347
query19	223	209	163	163
query20	138	135	130	130
query21	226	139	119	119
query22	13621	13608	13471	13471
query23	17374	16678	16254	16254
query23_1	16345	16293	16340	16293
query24	7426	1786	1326	1326
query24_1	1314	1295	1348	1295
query25	553	489	424	424
query26	1302	332	175	175
query27	2732	553	351	351
query28	4479	2048	2054	2048
query29	1045	639	519	519
query30	302	229	205	205
query31	1130	1091	964	964
query32	101	82	81	81
query33	564	366	316	316
query34	1197	1171	689	689
query35	829	800	712	712
query36	1432	1473	1300	1300
query37	157	109	99	99
query38	3200	3173	3057	3057
query39	936	953	919	919
query39_1	887	864	891	864
query40	237	156	133	133
query41	73	72	69	69
query42	116	114	112	112
query43	331	333	297	297
query44	
query45	223	211	205	205
query46	1116	1219	783	783
query47	2390	2400	2292	2292
query48	420	453	312	312
query49	647	514	396	396
query50	1039	356	258	258
query51	4312	4374	4300	4300
query52	107	109	97	97
query53	263	283	215	215
query54	330	293	268	268
query55	95	94	93	93
query56	309	334	327	327
query57	1452	1463	1336	1336
query58	317	281	289	281
query59	1637	1711	1435	1435
query60	328	326	314	314
query61	158	155	154	154
query62	693	648	590	590
query63	248	203	205	203
query64	2446	815	649	649
query65	
query66	1734	490	368	368
query67	29889	29790	29535	29535
query68	
query69	467	345	308	308
query70	1057	1008	1003	1003
query71	306	269	268	268
query72	3112	2806	2464	2464
query73	866	761	444	444
query74	5108	4950	4846	4846
query75	2707	2626	2288	2288
query76	2294	1175	808	808
query77	408	421	323	323
query78	12483	12326	12014	12014
query79	1501	1084	778	778
query80	917	548	465	465
query81	490	282	249	249
query82	1310	157	121	121
query83	371	286	259	259
query84	260	144	115	115
query85	947	533	452	452
query86	436	353	304	304
query87	3426	3389	3255	3255
query88	3615	2800	2786	2786
query89	448	393	345	345
query90	1776	192	182	182
query91	182	168	144	144
query92	80	83	75	75
query93	1491	1549	871	871
query94	629	363	317	317
query95	663	396	435	396
query96	1056	814	346	346
query97	2709	2728	2615	2615
query98	239	232	230	230
query99	1191	1154	1035	1035
Total cold run time: 255013 ms
Total hot run time: 173055 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 75.76% (25/33) 🎉
Increment coverage report
Complete coverage report

@yujun777
Copy link
Copy Markdown
Contributor Author

run nonConcurrent

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 75.76% (25/33) 🎉
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