sollhui opened a new pull request, #61046:
URL: https://github.com/apache/doris/pull/61046
### Problem
After performing `REPLACE TABLE` (swap) followed by `DROP TABLE` on the
original table name,
restarting FE causes all routine load jobs targeting the original table to
be set to `CANCELLED`.
### Steps to Reproduce
1. Create table `tbl_test`
2. Create a routine load job on `tbl_test`
3. `ALTER TABLE tbl_main REPLACE WITH TABLE tbl_test PROPERTIES('swap' =
'true')`
→ `tbl_test` (by ID) is now registered under the name `tbl_main`
→ `tbl_main` (by ID) is now registered under the name `tbl_test`
4. `DROP TABLE tbl_test` (drops the old `tbl_main` data, now named
`tbl_test`)
5. Restart FE → routine load job state becomes `CANCELLED`
### Root Cause
`RoutineLoadJob.gsonPostProcess()` is called during image replay on FE
restart.
It re-parses the original `CREATE ROUTINE LOAD` SQL (`origStmt`) and calls
`CreateRoutineLoadInfo.validate()`, which calls `checkDBTable()` to look up
the
target table **by name**.
The name stored in `origStmt` is `tbl_test` (the name at creation time).
After the
swap + drop sequence, this name no longer exists in the catalog. The lookup
throws
`AnalysisException: Unknown table 'tbl_test'`, which is caught and the job
state is
set to `CANCELLED`.
The `tableId` field is already correctly persisted and still points to the
original
table object (now registered under `tbl_main`), but `gsonPostProcess()`
never uses it.
### Fix
Before calling `validate()` in `gsonPostProcess()`, resolve the **current**
table name
from the catalog using the persisted `tableId`, and override the stale name
parsed from
`origStmt`. If `tableId` resolves to a valid table, validation succeeds with
the correct
name. If the table has genuinely been deleted (no entry for `tableId`),
validation still
fails and the job is correctly cancelled.
### Changes
- `RoutineLoadJob.java`: in `gsonPostProcess()`, look up current table name
by `tableId`
before calling `validate()`, overriding the stale name from `origStmt`
- `CreateRoutineLoadInfo.java`: add `setTableName()` to allow the name
override
- Add regression test `test_routine_load_swap_table_restart`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]