heguanhui opened a new pull request, #71219:
URL: https://github.com/apache/doris/pull/71219

   ### Background
   
   `SHOW ROUTINE LOAD` is a Redirect command and forwards to the master FE, so 
it always reports the master's job state. `SELECT ... FROM 
information_schema.routine_load_jobs` is a normal query and does not forward: 
the FE planner puts a callback FE address in the plan, and the BE schema scan 
calls `FrontendService.fetchRoutineLoadJob` on that address to read the job 
list. The transition to `RUNNING` is deliberately not journaled, because the 
scheduler only picks `NEED_SCHEDULE` jobs and a follower promoted with 
`RUNNING` but no tasks would never be rescheduled.
   
   ### What problem does this PR solve?
   
   Issue Number: close #71218
   Related PR: None
   PR Type: Bugfix
   
   Problem Summary:
   On a follower FE, `SELECT * FROM information_schema.routine_load_jobs` 
reports `NEED_SCHEDULE` for jobs that are actually `RUNNING`, while `SHOW 
ROUTINE LOAD` reports `RUNNING` on the same FE. Monitoring and automation that 
read `STATE` from this table can make decisions on stale input, such as 
treating a running job as stuck and triggering false alarms or 
restart/scheduling actions. This is an indirect correctness problem, not just a 
display inconsistency. The fix makes the plan for `routine_load_jobs` point the 
schema-scan callback at the master FE under the existing 
`enable_schema_scan_from_master_fe` session variable, the same mechanism 
already used by `information_schema.tables`. Queries receive master state on 
every FE; behavior with the variable disabled is unchanged.
   
   ### Details
   
   - **Frequency**: Always when the job is RUNNING on master and the 
information_schema query is planned on a follower. Found by code review; 
reproducible with a multi-FE cluster.
   - **Root cause**: `SchemaScanNode.finalizeForNereids()` set the callback FE 
to the local address for `routine_load_jobs`. The BE scan then read the local 
`RoutineLoadManager`, whose state lags the master because `RUNNING` is 
intentionally not replayed from the edit log.
   - **Why existing tests missed it**: FE unit tests touching schema-scan 
planning covered backend-partitioned metadata tables, not the master-vs-local 
callback address. The regression suite 
`test_routine_load_job_info_system_table.groovy` queries this table but 
connects only to the master and checks other columns, never the callback 
address or follower state. No existing test checked which FE the scan calls 
back into.
   - **Fix**: Extend the `enableSchemaScanFromMasterFe` branch in 
`SchemaScanNode.finalizeForNereids()` to include `routine_load_jobs`, so the 
plan carries the master FE address and the existing BE-to-FE RPC reads master 
state. The routine-load state machine, edit log, failover path, and 
statement-level forwarding are unchanged.
   - **Other paths and branches**: `information_schema.load_jobs` uses the same 
local-FE callback pattern and has the same class of staleness; not fixed here. 
`information_schema.tables` already uses this mechanism. `processlist` and 
`active_queries` intentionally aggregate all FEs. Affected branches: master and 
maintained release branches; release branches not individually verified.
   
   ### Testing
   
   `./run-fe-ut.sh --run org.apache.doris.planner.SchemaScanNodeMasterFeTest` 
after a clean FE build: 4 tests run, 0 failures, 0 errors, 0 skipped. The test 
asserts the callback ip/port in the thrift plan for `routine_load_jobs` (master 
when enabled, local when disabled), plus regression coverage that `tables` 
still uses master and `load_jobs` still uses local.
   
   Added 
`load_p0/routine_load/test_routine_load_job_state_from_follower.groovy`: a 
docker 2-FE test that compares `SHOW ROUTINE LOAD` and 
`information_schema.routine_load_jobs` STATE on both master and follower. It is 
a docker suite and requires `enableKafkaTest=true`; the default regression 
config sets `excludeDockerTest=true`, so ordinary CI does not run it. Not run 
locally (no docker/Kafka environment). The FE unit test is the routine CI guard.
   
   ### Notes for Reviewers
   
   Persisting `RUNNING` to the edit log was considered and rejected: a follower 
promoted with `RUNNING` but no task list would never be scheduled, because the 
scheduler only picks `NEED_SCHEDULE` jobs. This fix deliberately leaves the 
state machine unchanged and corrects only where the information_schema scan 
reads from.
   
   ### Release note
   
   `SELECT ... FROM information_schema.routine_load_jobs` now reports master 
job state on follower FEs when `enable_schema_scan_from_master_fe` is enabled 
(default true).
   
   ### Check List (For Author)
   
   - Behavior changed: Yes; the information_schema query callback FE address 
for `routine_load_jobs`.
   - Does this need documentation: No.
   - Pre-submission status: Partially verified: FE build and FE unit test pass; 
the docker regression test was not run locally.
   
   ### AI Disclosure
   
   - Tool: CodeBuddy agent with Claude Opus 6.
   - Generated: code, tests, this description.
   - Human review: pending.
   


-- 
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]

Reply via email to