[BugFix] Replay compatibility broken for INSERT loads: txn replay callbacks are empty
Bug Description
Severity: CRITICAL
Component: Transaction Manager / Load
Source file: fe/fe-core/src/main/java/com/starrocks/load/loadv2/InsertLoadJob.java (line 284)
Root cause: replayOnVisible() and replayOnAborted() in InsertLoadJob are empty no-ops. When an FE crashes between the txn VISIBLE journal write and the OP_END_LOAD_JOB_V2 write, replay calls these empty methods and never finalizes the job state. Additionally, cancelResidualJob() skips jobs whose txn status is VISIBLE, so the job becomes irrecoverable without manual intervention.
Concrete failure scenario: FE is killed immediately after a large INSERT's transaction becomes VISIBLE. On restart, the job is stuck in QUEUEING (or LOADING) forever with SinkRows=0, even though data was actually committed.
Steps to Reproduce
CREATE DATABASE IF NOT EXISTS test_replay;
USE test_replay;
CREATE TABLE t_src (id INT, val VARCHAR(100))
DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES ('replication_num'='1');
CREATE TABLE t_dst (id INT, val VARCHAR(100))
DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES ('replication_num'='1');
INSERT INTO t_src
SELECT generate_series, CONCAT('val_', CAST(generate_series AS VARCHAR))
FROM TABLE(generate_series(1, 2000000));
-- Monitor fe.log for VISIBLE event, kill FE PID immediately after
INSERT INTO test_replay.t_dst SELECT * FROM test_replay.t_src;
-- After FE auto-restarts:
SHOW LOAD FROM test_replay ORDER BY CreateTime DESC LIMIT 1\GActual Behavior
After FE restart:
State=QUEUEING, SinkRows=0, ErrorMsg=NULL, LoadFinishTime=NULLJob remained QUEUEING for 3+ minutes with no progress and no recovery.
FE log replay sequence:
03:10:49.338 VISIBLE txn 7020 ← FE killed here
03:10:56.673 replayUpsertTransactionState txn 7020 VISIBLE → calls replayOnVisible() [EMPTY]
NO replayEndLoadJob for job 17028
NO cancelResidualJob abort (txn is VISIBLE, not UNKNOWN)Expected Behavior
Job should be FINISHED (data was committed and visible) or at minimum CANCELLED with a clear error. Must not remain indefinitely in QUEUEING with SinkRows=0 while 2M rows were actually written to the table.
Verification
InsertLoadJob (JobId=17028) was permanently stuck in QUEUEING state after FE was killed between the txn VISIBLE journal write and the OP_END_LOAD_JOB_V2 write. replayOnVisible() is a no-op and cancelResidualJob() skips jobs whose txn status is VISIBLE, leaving the job irrecoverable.
This bug was identified and reproduced by AI-assisted code review.
What type of issue is this:
- BugFix
Does this entail a change in behavior?
- Yes, this issue will result in a change in behavior.
Type of change:
- Miscellaneous: correctness bug fix
Checklist
- Fix needs a regression test
- Fix may need user documentation update
Test Environment
| Tested Version | 4.0.8-2090bfc |
| Cluster | Docker starrocks/allin1-ubuntu:latest, 1 FE, 1 BE |
Source: StarRocks/starrocks