github-actions[bot] commented on code in PR #62270:
URL: https://github.com/apache/doris/pull/62270#discussion_r3058045936
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java:
##########
@@ -747,8 +778,9 @@ public void onReplayCreate() throws JobException {
* @param replayJob
*/
public void replayOnUpdated(StreamingInsertJob replayJob) {
- if (!JobStatus.RUNNING.equals(replayJob.getJobStatus())) {
- // No need to restore in the running state, as scheduling relies
on pending states.
+ if (!JobStatus.RUNNING.equals(replayJob.getJobStatus())
+ && !JobStatus.RETRYING.equals(replayJob.getJobStatus())) {
+ // No need to restore in the running/retrying state, as scheduling
relies on pending states.
// insert TVF does not persist the running state.
// streaming multi task persists the running state when
commitOffset() is called.
setJobStatus(replayJob.getJobStatus());
Review Comment:
`JobManager.replayUpdateJob()` does not replace the whole
`StreamingInsertJob`; it calls `replayOnUpdated()`. After this PR the new TVF
fields depend on `lastTaskSuccessTime` and `autoResumeCount`, but neither field
is copied here. After an FE restart or image replay, `jobs()` will lose
`LastTaskSuccessTime`/`RetryInfo` even if the edit log contained newer values.
Please replay the new fields here, or explicitly treat them as runtime-only and
avoid presenting them as persisted job metadata.
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingJobSchedulerTask.java:
##########
@@ -74,36 +77,44 @@ private void handlePendingState() throws JobException {
}
streamingInsertJob.createStreamingTask();
streamingInsertJob.setSampleStartTime(System.currentTimeMillis());
+ // Only reset autoResumeCount on user-initiated start (PENDING),
+ // not on system auto-resume (RETRYING)
+ if (JobStatus.PENDING.equals(streamingInsertJob.getJobStatus())) {
+ streamingInsertJob.setAutoResumeCount(0);
+ }
streamingInsertJob.updateJobStatus(JobStatus.RUNNING);
- streamingInsertJob.setAutoResumeCount(0);
}
private void handleRunningState() throws JobException {
streamingInsertJob.processTimeoutTasks();
streamingInsertJob.fetchMeta();
}
- private void autoResumeHandler() throws JobException {
- final FailureReason failureReason =
streamingInsertJob.getFailureReason();
+ private void handleRetryingState() throws JobException {
final long latestAutoResumeTimestamp =
streamingInsertJob.getLatestAutoResumeTimestamp();
final long autoResumeCount = streamingInsertJob.getAutoResumeCount();
+ final long maxAutoResumeCount =
streamingInsertJob.getMaxAutoResumeCount();
final long current = System.currentTimeMillis();
- if (failureReason != null
- && failureReason.getCode() !=
InternalErrorCode.MANUAL_PAUSE_ERR
- && failureReason.getCode() !=
InternalErrorCode.TOO_MANY_FAILURE_ROWS_ERR
- && failureReason.getCode() !=
InternalErrorCode.CANNOT_RESUME_ERR) {
- long autoResumeIntervalTimeSec = autoResumeCount < 5
- ? Math.min((long) Math.pow(2, autoResumeCount) *
BACK_OFF_BASIC_TIME_SEC,
- MAX_BACK_OFF_TIME_SEC) : MAX_BACK_OFF_TIME_SEC;
- if (current - latestAutoResumeTimestamp >
autoResumeIntervalTimeSec * 1000L) {
- streamingInsertJob.setLatestAutoResumeTimestamp(current);
- if (autoResumeCount < Long.MAX_VALUE) {
- streamingInsertJob.setAutoResumeCount(autoResumeCount + 1);
- }
- streamingInsertJob.updateJobStatus(JobStatus.PENDING);
- return;
- }
+ // Exceeded max retry count, give up and transition to PAUSED
+ if (autoResumeCount >= maxAutoResumeCount) {
+ String lastError = streamingInsertJob.getFailureReason() != null
+ ? streamingInsertJob.getFailureReason().getMsg() :
"unknown";
+ streamingInsertJob.setFailureReason(new FailureReason(
+ InternalErrorCode.CANNOT_RESUME_ERR,
+ "Auto resume failed after " + autoResumeCount
+ + " attempts. Last error: " + lastError));
+ streamingInsertJob.updateJobStatus(JobStatus.PAUSED);
+ return;
+ }
+
+ long autoResumeIntervalTimeSec = Math.min(
+ (long) Math.pow(2, autoResumeCount) * BACK_OFF_BASIC_TIME_SEC,
+ MAX_BACK_OFF_TIME_SEC);
+ if (current - latestAutoResumeTimestamp > autoResumeIntervalTimeSec *
1000L) {
+ streamingInsertJob.setLatestAutoResumeTimestamp(current);
+ streamingInsertJob.setAutoResumeCount(autoResumeCount + 1);
+ handlePendingState();
}
}
Review Comment:
`latestAutoResumeTimestamp` is still `0` the first time a job transitions
from `RUNNING` to `RETRYING`. On the next scheduler tick this condition is
immediately true, so the first retry happens with no backoff at all. That
breaks the new `RETRYING` semantics and also burns one auto-resume attempt
earlier than users expect. Please stamp the retry start time when entering
`RETRYING` (or otherwise initialize it before this comparison).
--
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]