Repository navigation
fix: retry failed terminal task status writes during storage sync - #20874
Conversation
FrankChen021
left a comment
There was a problem hiding this comment.
⚪ Review incomplete
PR 20874 currently has a definite merge conflict with master (mergeable=CONFLICTING, mergeStateStatus=DIRTY) at head c260b616b2b4d68eb2f0e43356579b909ca9c17a. Please resolve the conflicts with master and push a new head; review is deferred until then.
Reviewed 0 changed files; no code review was performed because the PR conflicts with master.
This is an automated review by Codex GPT-5.6-Luna(max)
FrankChen021
left a comment
There was a problem hiding this comment.
🟡 Changes recommended
The terminal-status retry path is correctly synchronized and prevents completed tasks from being rerun. However, the new persistence-failure metric is not registered in the default metric allowlist or emitter mappings, so it is silently unavailable with common configured emitters. Add those registrations before merging.
Reviewed 3 of 3 changed files.
Validation: git diff --check passed. No build or tests were run; this was a static review.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
This is an automated review by Codex GPT-5.6-Luna(max)
After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.
| .emit(); | ||
| final ServiceMetricEvent.Builder metricBuilder = ServiceMetricEvent.builder(); | ||
| IndexTaskUtils.setTaskDimensions(metricBuilder, task); | ||
| emitter.emit(metricBuilder.setMetric("task/status/persistFailed/count", 1)); |
There was a problem hiding this comment.
[P2] Register the new metric with emitter mappings
Finding: The new task/status/persistFailed/count metric is emitted here, but it is absent from the default logging-emitter allowlist and the default Dropwizard, StatsD, Prometheus, and OpenTSDB metric mappings. With metric filtering enabled or any of those default mapping-based emitters, the event is silently dropped, so operators cannot observe the persistence failures this PR is intended to expose.
Suggestion: Add the metric to each applicable default metric configuration and cover its registration with focused emitter tests.
There was a problem hiding this comment.
Confirmed fixed at head 857dcd9: task/status/persistFailed/count is registered in the default logging allowlist and Dropwizard, StatsD, Prometheus, and OpenTSDB mappings, with focused tests updated. Reviewed 12 of 12 changed files; no remaining actionable issue found.
5bb6cd0 to
e9f3adf
Compare
Resolve TaskQueueTest additions by retaining both status persistence tests and upstream task-count tests.
FrankChen021
left a comment
There was a problem hiding this comment.
🟢 Approval recommended
The prior P2 is fixed at the reviewed head. The persistence-failure metric is now registered in the logging allowlist and all four default emitter mappings, with focused tests updated.
Follow-up assessment
Reviewed 12 of 12 changed files. No remaining actionable issues found.
Validation: git diff --check a48de36c04ae1f0d8e9c51f87489d52faf2898ef..857dcd99ceb2250ff993f073a0f4fa938d445aaf passed. No build or tests were run; this was a static follow-up review.
This is an automated review by Codex
| final Collection<TaskInfo> removedTasks = mapDifference.entriesOnlyOnLeft().values(); | ||
|
|
||
| // Retry failed writes of terminal task statuses for tasks still active in storage. | ||
| for (final String taskId : mapDifference.entriesDiffering().keySet()) { |
There was a problem hiding this comment.
This retries every completed entry that the snapshot still lists, including tasks whose write succeeded after getActiveTaskInfos() read the DB. For those, persistTaskStatus finds a terminal status and fires the "Ignoring notification for already-complete task" alert. Every completion during the sync window triggers it. Could TaskEntry track whether the persist failed, and retry only those entries without alerting when storage is already terminal?
There was a problem hiding this comment.
for (TaskEntry e : activeTasks.values()) {
if (e.persistFailed && newTasks.containsKey(e.getTask().getId())) {
// compute() on that id, re-check the flag inside, then retry
}
}
There was a problem hiding this comment.
Updated in the latest commit, PTAL. Retries now track only persistence failures, recheck under the per-task lock, and stop without alerting when storage is already terminal.
FrankChen021
left a comment
There was a problem hiding this comment.
🟡 Changes recommended
Make completion cleanup independent of persistence-failure reporting before merging. If alert or metric emission throws while reporting a persistence failure, notifyStatus exits before shutting down the runner, releasing task locks, emitting completion metrics, and requesting management. A later storage sync retries persistence but does not retry those cleanup operations.
Reviewed 12 of 12 changed files. The incremental review covered the two files changed since 857dcd99ceb2250ff993f073a0f4fa938d445aaf; the full scope also covered metric documentation, default emitter mappings, and focused tests.
Validation: git diff --check a48de36c04ae1f0d8e9c51f87489d52faf2898ef..6e612863cda7c8add001a1995c1babf00d5661e6 passed. No tests or builds were run; this was a static review.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
This is an automated review by Codex GPT-5.6-Luna(max)
After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.
| .emit(); | ||
| final ServiceMetricEvent.Builder metricBuilder = ServiceMetricEvent.builder(); | ||
| IndexTaskUtils.setTaskDimensions(metricBuilder, task); | ||
| emitter.emit(metricBuilder.setMetric("task/status/persistFailed/count", 1)); |
There was a problem hiding this comment.
[P2] Keep completion cleanup independent of emitter failures
Finding: When persistence fails, the alert emission above or this synchronous metric emission can throw. The exception escapes before notifyStatus reaches shutdownTaskOnRunner, removeTaskLock, emitTaskCompletionLogsAndMetrics, and requestManagement. The retry flag lets a later storage sync persist and remove the completed entry, but those cleanup operations are never retried, leaving runner, lock, and completion-counter state stale.
Suggestion: Make alert and metric reporting best-effort or otherwise guarantee the normal completion cleanup runs after a persistence failure; extend the emitter-failure test to assert runner shutdown, lock release, and completion metrics.
6e61286 to
ae0c9ef
Compare
FrankChen021
left a comment
There was a problem hiding this comment.
🟢 Approval recommended
The prior persistence-reporting issue is fixed. Alert and metric emitter exceptions no longer prevent runner shutdown, lock release, completion accounting, management notification, or later terminal-status retries. The full retry path preserves terminal task state and prevents completed tasks from being rerun.
Reviewed 12 of 12 changed files. The incremental review covered the two files changed since the previous reviewed head; the full scope included metric documentation, emitter registrations, allowlists, and focused tests.
Validation: git diff --check a48de36c04ae1f0d8e9c51f87489d52faf2898ef..ae0c9efd080429e7f4265ce8d6e4c59f0abbf20b passed. No tests or builds were run; this was a static review.
This is an automated review by Codex GPT-5.6-Luna(max)
FrankChen021
left a comment
There was a problem hiding this comment.
🟢 Approval recommended
No actionable issues found in this review. The retry path preserves terminal task state, prevents reruns, and keeps cleanup independent of persistence-reporting failures. The new metric is documented and registered across the default emitters and logging allowlist.
Reviewed 12 of 12 changed files.
Validation: git diff --check a48de36 ae0c9ef passed. No build or tests were run; this was a static review.
This is an automated review by Codex GPT-5.6-Luna(max)
Description
When a terminal task status cannot be persisted,
TaskQueuemarks the task complete in memory while metadata still lists it as active. Further completion notifications are ignored, and periodic storage synchronization previously left this mismatch unresolved. This can cause task-list APIs to report finished tasks as active indefinitely.This PR retries terminal-status writes during
syncFromStorage()for tasks completed in memory but still active in metadata.The retry uses the existing per-task synchronization and persistence checks. Completed entries remain in memory until a subsequent storage snapshot confirms completion, preventing them from being re-added for execution. Retries preserve the original terminal status, duration, error message, and worker location without repeating shutdown or completion metrics.
The persistence logic is extracted into
persistTaskStatus(), shared by initial completion notifications and synchronization retries. Failed persistence attempts emit the existing alert and a newtask/status/persistFailed/countmetric.Validation
Added regression tests in the existing
TaskQueueTestcovering failed writes and reads, recovery, lost commit acknowledgements, stale snapshots, preserved completion details and duplicate-run prevention.Release note
Fixed an issue where completed ingestion tasks could remain listed as active after a metadata-store write failure. The Overlord now retries persisting their terminal statuses during periodic storage synchronization.
Key changed classes in this PR
This PR has: