Skip to content

[fix](streaming) avoid infinite retry when cloud mode job progress is not found - #66561

Closed
maks3201 wants to merge 1 commit into
apache:masterfrom
maks3201:fix/streaming-cloud-progress-not-found
Closed

[fix](streaming) avoid infinite retry when cloud mode job progress is not found#66561
maks3201 wants to merge 1 commit into
apache:masterfrom
maks3201:fix/streaming-cloud-progress-not-found

Conversation

@maks3201

@maks3201 maks3201 commented Aug 6, 2026

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: close #66560

Related PR: #66559 (independent fix in the same subsystem)

Problem Summary:

In compute-storage-decoupled (cloud) mode, replayOnCloudMode() asks MetaService for a streaming job's persisted progress. When MetaService answers STREAMING_JOB_PROGRESS_NOT_FOUND (expected for newly created jobs that have not yet committed a transaction), the method logs a warning and returns void. The caller — handlePendingState() in StreamingJobSchedulerTask — cannot distinguish "no progress exists" from "progress loaded successfully", so it repeats the RPC on every scheduler tick indefinitely.

Consequences:

  • The job is stuck in PENDING forever
  • FE log fills with repeated WARN messages
  • During journal replay at FE startup, every UPDATE_JOB edit-log entry triggers a doomed RPC

Fix:

  • Change replayOnCloudMode() return type from void to boolean (returns false on NOT_FOUND)
  • Add a transient volatile boolean cloudProgressMissing flag that short-circuits subsequent attempts
  • Clear the flag in afterCommitted() when the job commits its first transaction (progress now exists in MetaService)
  • Guard the journal-replay call site with !cloudProgressMissing to avoid repeated RPCs during startup

The flag is intentionally transient (not serialized): it resets on FE restart, giving MetaService another chance if the issue was temporary. A permanent NOT_FOUND is the expected state for newly created jobs — the fix simply allows the job to proceed rather than spinning.

Release note

Fix streaming insert job stuck in PENDING state with infinite MetaService retries in compute-storage-decoupled (cloud) mode. When MetaService returns STREAMING_JOB_PROGRESS_NOT_FOUND, the job now proceeds with its configured offset instead of retrying indefinitely.

Check List (For Author)

  • Test
    • Regression test
    • Unit Test
    • Manual test (all round) — verified on a compute-storage-decoupled cluster: new job transitions from PENDING to RUNNING within one scheduler tick, log spam eliminated
    • No need to test or manually tested. Explain why:
  • This is a refactor/code-cleanup without behavior change.
  • Code quality
    • Does not introduce new code style issues (checked with checkstyle)
    • Does not introduce new @Nullable warnings
    • Boundary conditions and error handling are adequate

Note to Reviewers

A unit test mocking MetaServiceProxy to return STREAMING_JOB_PROGRESS_NOT_FOUND and asserting the method returns false / the flag suppresses a second call is feasible and straightforward. I have not included one in this PR — happy to add it if reviewers prefer. The behavioral correctness was verified on a live cluster.

CC @JNSimba — as the streaming-job subsystem maintainer.

If this should be backported to 4.1, please apply the dev/4.1.x label (I cannot as a non-committer).

… not found

In compute-storage-decoupled (cloud) mode, replayOnCloudMode() asks MetaService
for a streaming job's persisted progress. When MetaService answers
STREAMING_JOB_PROGRESS_NOT_FOUND, the method logs a warning and returns void.
The caller cannot tell 'no progress exists' from 'progress loaded successfully',
so it repeats the RPC on every scheduler tick indefinitely, flooding the log
and leaving the job stuck in PENDING.

Fix:
- Change replayOnCloudMode() to return boolean (false on NOT_FOUND).
- Add a transient cloudProgressMissing flag that short-circuits subsequent
  attempts so the pointless RPC is not re-issued on every tick or journal entry.
- Clear the flag in afterCommitted() when the job actually persists progress,
  enabling recovery after MetaService later stores valid state.

The flag is intentionally transient (not serialized): it resets on FE restart,
which gives MetaService another chance if the issue was temporary. This is the
correct behavior — a permanent NOT_FOUND is expected for newly created jobs
that have not yet committed their first transaction.
@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?

@maks3201

maks3201 commented Aug 6, 2026

Copy link
Copy Markdown
Author

This bug is present in released 4.1.x (confirmed on 4.1.2). If the fix is accepted, the dev/4.1.x label would be appropriate for backport. I cannot apply labels as a non-committer — requesting a maintainer's help.

@maks3201

maks3201 commented Aug 7, 2026

Copy link
Copy Markdown
Author

Thank you for the detailed triage. You are right on the main point and I want to state that plainly.

What I got wrong. The claim that STREAMING_JOB_PROGRESS_NOT_FOUND leaves a job stuck in PENDING is incorrect. I traced it again. replayOnCloudMode() does a plain return on NOT_FOUND, it does not throw, so the catch block in handlePendingState() never runs and execution continues to createStreamingTask() and updateJobStatus(JobStatus.RUNNING) in the same invocation (StreamingJobSchedulerTask.java:57-82). The job only goes to PAUSED when the RPC throws, which NOT_FOUND does not. I inferred the stuck state from reading the code and the inference was wrong. I also have no captured job status output or log excerpt showing a job in PENDING, so there was no observation behind it either.

I also want to correct a second thing before it spreads. I had thought this produced repeated warnings on every scheduler tick. That is also wrong. replayOnCloudMode() is reachable from only two places, handlePendingState() and replayOnUpdated(). handleRunningState() only calls processTimeoutTasks(), fetchMeta() and advanceSplitsIfNeed(), so once the job is RUNNING there is no further call and no per tick repetition.

What actually holds up. Only one thing, and it is smaller than I described. EditLog replay calls JobManager.replayUpdateJob() (EditLog.java:886), which reaches replayOnUpdated(), which calls replayOnCloudMode() unconditionally in cloud mode (StreamingInsertJob.java:1038-1040). So each replayed UPDATE_JOB entry issues one MetaService RPC with no deduplication, and for a job that never committed each one returns NOT_FOUND and logs two WARN lines. I should also retract the wording about blocking until timeout. NOT_FOUND is a normal fast response with a non OK status code, the timeout case only applies when MetaService is unreachable, so my "wedge FE startup" description was an overstatement.

What I am doing. Closing this PR and the issue. What is left is a minor replay deduplication and a log level change, and it does not match what the issue and PR describe. Reframing them would leave a misleading history. If I revisit it, I will open a fresh narrow PR for replay deduplication only, with startup timing numbers and entry counts to justify it, plus the unit tests you asked for.

Thank you for looking at this carefully. Your review caught a real error on my side.

@maks3201 maks3201 closed this Aug 7, 2026
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] Streaming job stuck in PENDING with infinite MetaService retries in cloud mode

2 participants