JNSimba opened a new pull request, #62345:
URL: https://github.com/apache/doris/pull/62345
### What problem does this PR solve?
Related PR: #62270 (earlier attempt that introduced a new `RETRYING` state —
superseded by this smaller, state-machine-preserving change)
Problem Summary:
`StreamingInsertJob` currently has three related gaps that combine into a
silent failure mode for broken streaming jobs:
1. **No retry budget.** `autoResumeHandler` retries forever — once
exponential backoff caps out it keeps hammering at the max interval
indefinitely, so a permanently broken job quietly wastes BE resources and fills
logs without anyone noticing.
2. **Unstructured `ErrorMsg`.** The `jobs("type"="insert")` TVF only exposes
`FailureReason.msg`. The frontend cannot tell whether a `PAUSED` job is (a)
manually paused, (b) auto-recovering from a transient error, or (c) a
non-recoverable failure — the only way to discriminate is to pattern-match the
error message string.
3. **Scheduler-driven state transitions are not persisted.**
`StreamingInsertJob.updateJobStatus` doesn't call `logUpdateOperation()`, so
the `PAUSED + FailureReason` state written by `onStreamTaskFail`, `fetchMeta`
failure, and cloud replay failure is lost on FE restart.
#### Design decision: no new `JobStatus` value
An earlier attempt (#62270) introduced a `RETRYING` state. This PR takes a
simpler route: keep the existing 5-value `JobStatus` enum unchanged and let the
frontend derive the user-facing state from `(Status, FailureReason.code)`. The
reasoning:
- `FailureReason.code` already cleanly partitions `PAUSED` into "manual",
"auto-recovering" and "non-recoverable"
- Adding a new enum value forces persistence format churn, replay
special-casing, and rolling-upgrade compatibility shims
- A max retry budget backed by `CANNOT_RESUME_ERR` gives us the same "system
has given up" signal without introducing a new state
#### Key changes
- **New config `streaming_job_max_auto_resume_count`** (masterOnly, mutable,
default 10). Once the retry budget is exhausted, `autoResumeHandler` rewrites
the failure reason to `CANNOT_RESUME_ERR` with a summary of the last error,
which makes subsequent ticks short-circuit at the existing resumable-reason
check. No new state.
- **`ErrorMsg` column now returns a FailureReason JSON blob**
(`{"code":"...","msg":"..."}`) via `GsonUtils.GSON.toJson(failureReason)`.
Existing `.contains(...)` assertions in regression tests continue to work
because the message string is embedded in the JSON.
- **New `LastTaskSuccessTime` TVF column** so operators can see at a glance
whether a streaming job is making real progress.
- **`StreamingInsertJob.updateJobStatus` now calls `logUpdateOperation()`
for every non-RUNNING transition**, so scheduler-driven PAUSED+FailureReason
state survives FE restart. RUNNING is skipped because it's purely transient and
`replayOnUpdated()` already refuses to restore it.
- **Fix latent exponential backoff bug.** `handlePendingState` was resetting
`autoResumeCount` to 0 on every `PENDING → RUNNING` transition, which meant the
backoff interval was stuck at the base value across repeated failures and the
max retry budget was never enforced. The counter is now reset only in
`resetFailureInfo(null)`, which fires on successful task completion and on
`RESUME JOB` — so exponential backoff and the retry budget actually accumulate
across failed retries as intended.
- **Drop erroneous `super.cancelAllTasks`** call. The parent `runningTasks`
list holds `StreamingJobSchedulerTask` entries whose `executeCancelLogic` is a
no-op, and the call was also wrongly incrementing `canceledTaskCount` with
scheduler ticks. The real data task (`AbstractStreamingTask`) is handled
separately via `runningStreamTask`.
- **`autoResumeCount` and `latestAutoResumeTimestamp` are intentionally not
`@SerializedName`-annotated**: an FE restart resets the retry budget, which is
the desired "restart = fresh retry chance" semantic. Strict cross-restart
enforcement would be surprising and rarely the user's intent.
### Release note
Add `streaming_job_max_auto_resume_count` config (default 10) to cap
auto-resume attempts for streaming insert jobs. The `ErrorMsg` column in
`jobs("type"="insert")` now returns the full `FailureReason` as JSON so
frontends can discriminate on structured error codes. A new
`LastTaskSuccessTime` column exposes the time of the last successful task
commit.
### Check List (For Author)
- Test
- [x] Regression test (`test_streaming_job_max_retry`,
`test_streaming_insert_job` extended with `LastTaskSuccessTime` assertion)
- [ ] Unit Test
- [ ] Manual test
- [ ] No need to test or manual test
- Behavior changed:
- [x] Yes.
- `ErrorMsg` column format: plain `FailureReason.msg` →
`{"code":"...","msg":"..."}` JSON. Existing `.contains(...)` assertions are
unaffected because the message string is embedded.
- New `LastTaskSuccessTime` TVF column appended to `InsertJob` schema
— may break positional column access.
- Streaming jobs with a persistent failure now hit the circuit breaker
after `streaming_job_max_auto_resume_count` attempts instead of retrying
forever.
- `StreamingInsertJob.updateJobStatus` now writes editlog on every
non-RUNNING transition.
- Does this need documentation?
- [x] Yes. <!-- TODO: add docs PR for
streaming_job_max_auto_resume_count and the new ErrorMsg JSON shape -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]