[Bug] Table stuck in WAITING_STABLE after cancelling a schema-change job that never became stable
- Dominant language
- Java
- Stars
- 15.9k
- Forks
- 3.9k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 520
Description
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.
### Version
master
### What's Wrong?
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's `OlapTableState` is **not** reset back to `NORMAL`.
Root cause: `SchemaChangeJobV2.changeTableState` (invoked from the job's `cancelInternal`) only resets the table when its state is `SCHEMA_CHANGE`; a table in `WAITING_STABLE` is left untouched. In addition, `SchemaChangeHandler.cancelColumnJob` throws "could not find related job" when a table is flagged `WAITING_STABLE` but has no live job (an orphaned state older binaries could leave behind).
As a result the table stays permanently stuck in `WAITING_STABLE` with no live job, and every subsequent `ALTER` / `TRUNCATE` / `DROP PARTITION` / `RENAME` / `CANCEL ALTER` on it is rejected — the only way to recover is `DROP TABLE`.
### What You Expected?
Cancelling a schema-change job that is still `WAITING_STABLE` should reset the table back to `NORMAL` so it is usable again. A table left in an orphaned `WAITING_STABLE` (no backing job) should be self-healed by `CANCEL ALTER TABLE` rather than requiring `DROP TABLE`.
### How to Reproduce?
1. Start an `ALTER TABLE ... ADD COLUMN` on a table that is not stable (e.g. a replica in `DECOMMISSION`), so the pending schema-change job parks in `WAITING_STABLE`.
2. `CANCEL ALTER TABLE COLUMN FROM db.tbl`.
3. The table remains in `WAITING_STABLE`; subsequent ALTER/TRUNCATE/DROP PARTITION/RENAME/CANCEL are rejected.
### Anything Else?
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Contributor guide
Research direction
Start with SchemaChangeJobV2.changeTableState and its cancelInternal path, then inspect SchemaChangeHandler.cancelColumnJob. Reproduce the WAITING_STABLE case with ALTER TABLE ... ADD COLUMN followed by CANCEL ALTER TABLE COLUMN, including an orphaned state with no live job. Done means cancellation restores OlapTableState to NORMAL and orphaned WAITING_STABLE state can be self-healed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100