Skip to content

[fix](schema-change) reset table state when cancelling a job stuck in WAITING_STABLE - #66178

Open
Baymine wants to merge 1 commit into
apache:masterfrom
Baymine:fix/schema-change-waiting-stable-cancel
Open

[fix](schema-change) reset table state when cancelling a job stuck in WAITING_STABLE#66178
Baymine wants to merge 1 commit into
apache:masterfrom
Baymine:fix/schema-change-waiting-stable-cancel

Conversation

@Baymine

@Baymine Baymine commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #66177

Related PR: N/A

Problem Summary:

When a schema-change job is cancelled while the table is still in the WAITING_STABLE sub-state (the table never became stable, so the job was never promoted to SCHEMA_CHANGE), the table state was not reset back to NORMAL: SchemaChangeJobV2.changeTableState only reset from SCHEMA_CHANGE. The table was then permanently stuck in WAITING_STABLE with no live job, and every subsequent ALTER / TRUNCATE / DROP PARTITION / RENAME / CANCEL was rejected — the only escape was DROP TABLE.

This fixes it in two places:

  1. SchemaChangeJobV2.changeTableState now also resets the table from WAITING_STABLE (not just SCHEMA_CHANGE) when a job is cancelled, so the normal "cancel a WAITING_STABLE job" path returns the table to NORMAL.
  2. SchemaChangeHandler.cancelColumnJob now self-heals a table left in an orphaned WAITING_STABLE state with no backing job (which older binaries could produce) by resetting it to NORMAL durably via setTableStatusInternal, instead of throwing "could not find related job". An orphaned SCHEMA_CHANGE state (not a known-reachable state) still fails loudly so it is investigated rather than silently masked.

Release note

Fix a schema-change table state leak: cancelling a job that is stuck in WAITING_STABLE now correctly resets the table to NORMAL instead of leaving it permanently blocked for all subsequent ALTER operations.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Please explain why:
  • Behavior changed:

  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

… WAITING_STABLE

What problem does this PR solve?

Issue Number: close apache#66177

Problem Summary:
When a schema-change job is cancelled while the table is still in the
WAITING_STABLE sub-state (the table never became stable, so the job was
never promoted to SCHEMA_CHANGE), the table state was not reset back to
NORMAL: SchemaChangeJobV2.changeTableState only reset from SCHEMA_CHANGE.
The table was then permanently stuck in WAITING_STABLE with no live job,
and every subsequent ALTER / TRUNCATE / DROP PARTITION / RENAME / CANCEL
was rejected -- the only escape was DROP TABLE.

This fixes it in two places:
1. SchemaChangeJobV2.changeTableState now also resets the table from
   WAITING_STABLE (not just SCHEMA_CHANGE) when a job is cancelled, so the
   normal "cancel a WAITING_STABLE job" path returns the table to NORMAL.
2. SchemaChangeHandler.cancelColumnJob now self-heals a table left in an
   orphaned WAITING_STABLE state with no backing job (which older binaries
   could produce) by resetting it to NORMAL durably via
   setTableStatusInternal, instead of throwing "could not find related
   job". An orphaned SCHEMA_CHANGE state (not a known-reachable state) still
   fails loudly so it is investigated rather than silently masked.

Release note:
Fix a schema-change table state leak: cancelling a job that is stuck in
WAITING_STABLE now correctly resets the table to NORMAL instead of leaving
it permanently blocked for all subsequent ALTER operations.

Check List (For author)
- [x] Test <!-- At least one of them must be included. -->
    - [ ] Regression test
    - [x] Unit Test
    - [ ] Manual test (add detailed scripts or steps below)

- [ ] No need for documentation
@Baymine

Baymine commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

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

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 76.92% (10/13) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17648	4082	4031	4031
q2	2021	323	208	208
q3	10309	1409	794	794
q4	4675	472	344	344
q5	7500	863	566	566
q6	183	178	135	135
q7	791	809	618	618
q8	9330	1620	1651	1620
q9	5545	4327	4329	4327
q10	6725	1723	1505	1505
q11	519	351	321	321
q12	736	587	451	451
q13	18111	3348	2803	2803
q14	261	263	254	254
q15	q16	785	784	711	711
q17	996	1008	955	955
q18	7093	5812	5664	5664
q19	1316	1218	1101	1101
q20	784	682	605	605
q21	5856	2602	2226	2226
q22	433	359	296	296
Total cold run time: 101617 ms
Total hot run time: 29535 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4393	4298	4338	4298
q2	284	318	210	210
q3	4586	4954	4427	4427
q4	2073	2173	1375	1375
q5	4409	4278	4260	4260
q6	230	172	126	126
q7	1729	1638	2054	1638
q8	2596	2190	2185	2185
q9	7923	8071	7699	7699
q10	4734	4631	4232	4232
q11	576	418	379	379
q12	767	791	557	557
q13	3261	3689	2916	2916
q14	312	302	273	273
q15	q16	726	754	648	648
q17	1341	1331	1309	1309
q18	7915	7228	7098	7098
q19	1161	1133	1124	1124
q20	2218	2195	1922	1922
q21	5210	4504	4477	4477
q22	529	460	392	392
Total cold run time: 56973 ms
Total hot run time: 51545 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 178497 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 1285834baf361f77260745ea3d6598fb78051541, data reload: false

query5	4320	643	488	488
query6	471	219	195	195
query7	4849	586	337	337
query8	341	192	170	170
query9	8748	4109	4092	4092
query10	478	364	304	304
query11	5867	2345	2128	2128
query12	154	109	104	104
query13	1269	613	438	438
query14	6253	5279	4939	4939
query14_1	4285	4302	4260	4260
query15	220	200	181	181
query16	1016	464	452	452
query17	944	800	554	554
query18	2483	485	333	333
query19	206	189	141	141
query20	118	104	102	102
query21	228	161	133	133
query22	13538	13642	13390	13390
query23	17355	16620	16183	16183
query23_1	16174	16276	16225	16225
query24	7532	1788	1305	1305
query24_1	1313	1266	1295	1266
query25	534	433	360	360
query26	1328	382	224	224
query27	2584	580	371	371
query28	4418	1976	1942	1942
query29	1067	622	476	476
query30	337	271	232	232
query31	1108	1100	995	995
query32	127	65	59	59
query33	547	318	245	245
query34	1180	1162	629	629
query35	765	803	669	669
query36	1035	1021	884	884
query37	161	105	141	105
query38	1923	1720	1641	1641
query39	872	907	830	830
query39_1	837	854	843	843
query40	250	161	140	140
query41	64	63	64	63
query42	93	91	93	91
query43	329	324	278	278
query44	1471	782	753	753
query45	192	187	173	173
query46	1039	1206	753	753
query47	2140	2123	2007	2007
query48	386	399	306	306
query49	604	421	324	324
query50	1087	427	336	336
query51	10781	10506	10711	10506
query52	86	93	76	76
query53	281	296	204	204
query54	281	239	208	208
query55	77	74	65	65
query56	290	328	289	289
query57	1313	1268	1161	1161
query58	291	265	255	255
query59	1608	1645	1425	1425
query60	300	279	259	259
query61	160	154	163	154
query62	556	499	430	430
query63	247	207	198	198
query64	2887	1033	838	838
query65	4722	4635	4608	4608
query66	1852	494	377	377
query67	29233	29309	29027	29027
query68	3153	1602	1042	1042
query69	411	310	273	273
query70	897	817	834	817
query71	367	327	328	327
query72	3015	2747	2636	2636
query73	852	802	447	447
query74	5108	4931	4733	4733
query75	2561	2499	2139	2139
query76	2379	1199	783	783
query77	368	399	286	286
query78	11951	11771	11468	11468
query79	1417	1136	765	765
query80	927	593	497	497
query81	498	341	292	292
query82	855	163	122	122
query83	421	352	308	308
query84	352	165	142	142
query85	1050	684	608	608
query86	405	250	236	236
query87	1830	1823	1717	1717
query88	3758	2811	2766	2766
query89	455	378	334	334
query90	1812	199	196	196
query91	216	191	161	161
query92	63	62	55	55
query93	1585	1532	980	980
query94	640	340	326	326
query95	782	625	475	475
query96	1039	773	352	352
query97	2629	2612	2503	2503
query98	212	206	202	202
query99	1094	1122	986	986
Total cold run time: 263044 ms
Total hot run time: 178497 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.11	0.05	0.05
query3	0.30	0.14	0.14
query4	1.60	0.14	0.13
query5	0.24	0.22	0.22
query6	1.26	1.06	1.09
query7	0.04	0.00	0.00
query8	0.06	0.03	0.04
query9	0.39	0.31	0.31
query10	0.55	0.55	0.53
query11	0.19	0.14	0.14
query12	0.18	0.13	0.14
query13	0.48	0.48	0.48
query14	1.02	1.00	1.02
query15	0.61	0.60	0.60
query16	0.31	0.34	0.31
query17	1.10	1.08	1.11
query18	0.23	0.21	0.20
query19	2.13	1.98	1.95
query20	0.02	0.01	0.01
query21	15.43	0.21	0.13
query22	4.89	0.05	0.04
query23	16.15	0.31	0.13
query24	2.77	0.39	0.34
query25	0.12	0.05	0.04
query26	0.74	0.21	0.16
query27	0.04	0.04	0.03
query28	3.57	0.94	0.53
query29	12.54	4.03	3.25
query30	0.29	0.15	0.15
query31	2.77	0.59	0.31
query32	3.22	0.60	0.49
query33	3.14	3.17	3.23
query34	15.51	4.21	3.52
query35	3.53	3.53	3.53
query36	0.54	0.43	0.43
query37	0.11	0.07	0.06
query38	0.06	0.04	0.04
query39	0.04	0.04	0.03
query40	0.18	0.17	0.16
query41	0.08	0.03	0.03
query42	0.04	0.03	0.02
query43	0.05	0.04	0.04
Total cold run time: 96.64 s
Total hot run time: 25.01 s

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.

[Bug] Table stuck in WAITING_STABLE after cancelling a schema-change job that never became stable

2 participants