Skip to content

[fix](fe) Skip DEC journal when dictionary dropped during load commit - #66552

Open
zclllyybb wants to merge 1 commit into
apache:masterfrom
zclllyybb:codex/fix-doris-27820
Open

[fix](fe) Skip DEC journal when dictionary dropped during load commit#66552
zclllyybb wants to merge 1 commit into
apache:masterfrom
zclllyybb:codex/fix-doris-27820

Conversation

@zclllyybb

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

An async dictionary load task writes the INC version journal, then DROP deletes the dictionary, then a failed BE commit writes a DEC journal for the already dropped dictionary. Followers exit while replaying the DEC journal because the dictionary cannot be found by name anymore, and the cluster cannot recover since the bad journal is persistent.

Root cause: the commit failure rollback runs outside the manager lock and does not check whether the dictionary is still current, so DROP can interleave between the INC journal and the rollback DEC journal. Replay of the DEC journal looks the dictionary up by name and throws when it is gone, which makes EditLog.loadJournal exit the FE.

Fix: on commit failure, only persist the DEC journal while the dictionary is still the current one (identity check under the manager read lock), so the journal stream becomes CREATE -> INC -> DROP instead of CREATE -> INC -> DROP -> DEC. Replay of increase/decrease version journals is made idempotent and keyed by dictionary id, so a DEC journal of an already dropped or recreated dictionary is a no-op instead of a fatal error.

Release note

None

Check List (For Author)

  • Test: Unit test DictionaryManagerTest (replay idempotency, journal order CREATE -> INC -> DROP -> DEC, ABA recreated same-name dictionary) and docker regression test test_dictionary_drop_while_load_commit_fail (deterministic race reproduction via debug points).
  • Behavior changed: No
  • Does this need documentation: No

### What problem does this PR solve?

Problem Summary: An async dictionary load task writes the INC version journal, then
DROP deletes the dictionary, then a failed BE commit writes a DEC journal for the
already dropped dictionary. Followers exit while replaying the DEC journal because
the dictionary cannot be found by name anymore, and the cluster cannot recover since
the bad journal is persistent.

Root cause: the commit failure rollback runs outside the manager lock and does not
check whether the dictionary is still current, so DROP can interleave between the
INC journal and the rollback DEC journal. Replay of the DEC journal looks the
dictionary up by name and throws when it is gone, which makes EditLog.loadJournal
exit the FE.

Fix: on commit failure, only persist the DEC journal while the dictionary is still
the current one (identity check under the manager read lock), so the journal stream
becomes CREATE -> INC -> DROP instead of CREATE -> INC -> DROP -> DEC. Replay of
increase/decrease version journals is made idempotent and keyed by dictionary id, so
a DEC journal of an already dropped or recreated dictionary is a no-op instead of a
fatal error.

### Release note

None

### Check List (For Author)

- Test: Unit test DictionaryManagerTest (replay idempotency, journal order
  CREATE -> INC -> DROP -> DEC, ABA recreated same-name dictionary) and docker
  regression test test_dictionary_drop_while_load_commit_fail (deterministic race
  reproduction via debug points).
- Behavior changed: No
- 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?

@zclllyybb

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 63.64% (14/22) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17709	4025	3953	3953
q2	2063	325	208	208
q3	10318	1387	818	818
q4	4684	472	335	335
q5	7501	847	546	546
q6	178	167	133	133
q7	760	820	596	596
q8	9634	1632	1549	1549
q9	5689	4096	4057	4057
q10	6780	1640	1362	1362
q11	512	356	338	338
q12	750	578	465	465
q13	18093	3197	2737	2737
q14	274	252	240	240
q15	q16	732	725	658	658
q17	945	1008	958	958
q18	6610	5612	5613	5612
q19	1314	1218	1012	1012
q20	791	655	543	543
q21	5607	2565	2366	2366
q22	420	353	302	302
Total cold run time: 101364 ms
Total hot run time: 28788 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4309	4231	4218	4218
q2	278	321	209	209
q3	4504	4894	4342	4342
q4	2176	2245	1423	1423
q5	4240	4151	4109	4109
q6	232	166	123	123
q7	1700	1545	1437	1437
q8	2716	2084	2041	2041
q9	7354	7254	7359	7254
q10	4302	4264	3853	3853
q11	589	429	377	377
q12	710	726	505	505
q13	3195	3479	3099	3099
q14	293	312	287	287
q15	q16	700	709	660	660
q17	1369	1360	1315	1315
q18	12193	11025	11764	11025
q19	1167	1149	1152	1149
q20	2216	2249	1917	1917
q21	5644	4956	4512	4512
q22	521	464	406	406
Total cold run time: 60408 ms
Total hot run time: 54261 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 165648 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 267037c935bc6816baad8f7aaa1b9eaa39554199, data reload: false

query5	4357	605	449	449
query6	485	222	200	200
query7	4889	605	337	337
query8	335	164	154	154
query9	8824	4102	4085	4085
query10	513	375	312	312
query11	5682	2213	2010	2010
query12	158	104	95	95
query13	1282	588	433	433
query14	6095	4262	3985	3985
query14_1	3823	3797	3807	3797
query15	205	203	179	179
query16	1029	506	427	427
query17	1128	718	561	561
query18	2442	484	356	356
query19	216	193	152	152
query20	110	103	105	103
query21	233	162	141	141
query22	13010	13167	12757	12757
query23	15820	14871	14638	14638
query23_1	14593	14508	14595	14508
query24	7589	1687	1261	1261
query24_1	1255	1268	1252	1252
query25	555	447	384	384
query26	1300	347	219	219
query27	2588	606	375	375
query28	4536	2040	1998	1998
query29	1078	639	519	519
query30	335	260	222	222
query31	1190	1110	1038	1038
query32	110	62	62	62
query33	518	303	236	236
query34	1149	1121	639	639
query35	744	743	620	620
query36	785	780	715	715
query37	156	110	90	90
query38	1839	1776	1678	1678
query39	822	823	801	801
query39_1	785	790	801	790
query40	256	167	142	142
query41	66	61	62	61
query42	94	92	99	92
query43	325	324	275	275
query44	1439	777	763	763
query45	187	171	172	171
query46	1042	1205	713	713
query47	1546	1552	1439	1439
query48	378	408	306	306
query49	600	416	295	295
query50	1071	415	314	314
query51	10605	10443	10166	10166
query52	87	93	76	76
query53	258	285	204	204
query54	275	235	222	222
query55	75	71	73	71
query56	323	302	301	301
query57	1013	989	922	922
query58	277	262	265	262
query59	1510	1584	1474	1474
query60	345	268	262	262
query61	150	144	152	144
query62	404	315	267	267
query63	234	197	193	193
query64	2845	1028	834	834
query65	3866	3826	3785	3785
query66	1823	482	364	364
query67	28109	28113	27777	27777
query68	3086	1500	1010	1010
query69	404	306	271	271
query70	895	794	826	794
query71	366	334	321	321
query72	2997	2617	2333	2333
query73	846	778	437	437
query74	4627	4470	4296	4296
query75	2356	2338	1993	1993
query76	2335	1130	749	749
query77	345	365	272	272
query78	11153	11052	10538	10538
query79	1443	1186	759	759
query80	1247	539	459	459
query81	521	330	283	283
query82	617	171	136	136
query83	376	324	302	302
query84	278	172	132	132
query85	958	607	535	535
query86	412	240	212	212
query87	1960	1968	1830	1830
query88	3784	2802	2785	2785
query89	411	319	284	284
query90	1915	194	196	194
query91	202	188	167	167
query92	64	61	59	59
query93	1671	1527	990	990
query94	714	328	325	325
query95	784	500	482	482
query96	1128	798	369	369
query97	2451	2452	2316	2316
query98	196	190	181	181
query99	749	730	619	619
Total cold run time: 253280 ms
Total hot run time: 165648 ms

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.10	0.05	0.05
query3	0.25	0.14	0.14
query4	1.61	0.14	0.15
query5	0.25	0.23	0.22
query6	1.17	0.81	0.84
query7	0.03	0.01	0.00
query8	0.06	0.04	0.04
query9	0.38	0.33	0.33
query10	0.56	0.59	0.54
query11	0.20	0.13	0.14
query12	0.18	0.14	0.14
query13	0.48	0.46	0.47
query14	1.00	0.99	1.01
query15	0.60	0.60	0.59
query16	0.32	0.33	0.33
query17	1.09	1.12	1.13
query18	0.21	0.19	0.19
query19	2.01	2.00	2.00
query20	0.02	0.01	0.01
query21	15.42	0.24	0.15
query22	4.82	0.05	0.06
query23	16.12	0.30	0.13
query24	2.97	0.37	0.32
query25	0.11	0.04	0.04
query26	0.72	0.21	0.14
query27	0.05	0.04	0.04
query28	3.50	0.79	0.35
query29	12.49	3.99	3.18
query30	0.28	0.16	0.18
query31	2.77	0.56	0.31
query32	3.23	0.59	0.50
query33	3.25	3.17	3.18
query34	15.38	3.91	3.28
query35	3.23	3.20	3.24
query36	0.58	0.44	0.45
query37	0.08	0.07	0.06
query38	0.05	0.04	0.04
query39	0.03	0.03	0.03
query40	0.18	0.15	0.14
query41	0.09	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 95.94 s
Total hot run time: 24.04 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 1.24% (4/323) 🎉
Increment coverage report
Complete coverage report

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.

2 participants