mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
dfee72ea311cbb3b09e10dee83de1ebad6647869
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
374c77bcbe |
admin/plugin: fail a restored job its worker no longer lists (#12815)
* admin/plugin: fail a restored job its worker no longer lists An admin restart reloads the jobs that were running from the persisted state, but the workers drop those jobs when the old admin stream closes. No pending execution covers a restored job, so only the 24h stale sweep ended it, and until then it blocked dedupe and scheduling of its job type. Track the active jobs loaded at startup by worker and fail one after two itemized heartbeats from its worker leave it out, as is already done for a dispatch whose worker restarted. A listed job is left to adoption. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: keep tracking a listed restored job; skip queued ones - A restored job its worker lists only resets its miss count, so one it drops later is still failed. - Track only jobs that were sent to a worker (request id set, not pending). - Match restored ids against the trimmed heartbeat ids. - Fail the restored attempt under the jobs lock that applies the expiry (handleJobCompletedIf / expireActiveJobIf), so a newer attempt of the same job is neither failed nor canceled. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: keep a newer attempt's detail from a restored-job expiry - The conditional completion writes the job detail through persistJobDetailSnapshotIf and skips it when the stored detail already names another request; the check runs under jobDetailsMu with the write. - mergeTerminalDetailIntoTracked ignores a terminal detail of another request, so a restart does not end the loaded attempt with it. - Tests wait for the restored-job expiries instead of sleeping. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: restore a finished retry from its detail The job detail is saved as each attempt changes and the job list only periodically, so a terminal detail naming another request is the newer attempt. Apply it with its request id instead of ignoring it; the expiry's own detail write already refuses to overwrite another request. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: restore whichever attempt is newer The job list and a job's detail can name different attempts either way round: the list is saved periodically, and a detail write can fail. When their request ids differ, apply the terminal detail only if it is the newer attempt (higher attempt number, else later update). Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: fill a restored job's empty request id from its detail A job the list saved while still queued has no request id; take the finished detail's, as the merge did before the newer-attempt check. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: take the worker and attempt of a newer restored detail When the restore takes a finished retry's detail over the job list's attempt, the record kept the older attempt's worker and attempt number next to the retry's request id and state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: fold the conditional completion into the existing functions handleJobCompleted, expireActiveJob, trackExecutionCompletion and persistJobDetailSnapshot take the accept check themselves instead of gaining *If twins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: ignore a late earlier-attempt completion; replace an older detail - A completion whose request id differs from the tracked attempt's is a late report of an earlier attempt and no longer ends a retry. - A conditional completion skips the detail write only when the stored detail is a newer attempt (detailIsNewerAttempt), so an older finished attempt's detail left behind by a failed write is replaced. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: take only the dispatched attempt's reports A late progress report of a timed-out attempt replaced the retry's request id, after which the retry's own completion was rejected as foreign. One rule now gates both: a record the admin dispatched (attempt > 0) takes progress and completion only for its own request (reportFromOtherAttempt). When an expiry replaces an older attempt's detail it also takes the closing attempt's worker, attempt number and times. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: restore a newer running attempt's identity from its detail The job list can name attempt A while the detail shows retry B running when the admin stopped. The restore now takes B's request id, worker and attempt number from such a newer running detail, so B's own reports are accepted. Test helper keeps a given attempt number. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: keep attemptEnded's doc comment on attemptEnded Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: dispatch an attempt-less job as attempt 1 The late-report guard only covers records with a positive attempt, and ExecuteJob passed a zero attempt through, so a direct caller's dispatch could be closed by another request's completion. The HTTP API already raised zero to one; the dispatch path now does the same for every caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7047d3947a |
admin/plugin: fail a dispatch its restarted worker no longer lists (#12402)
* admin/plugin: fail a dispatch its restarted worker no longer lists A job dispatched to a worker that then restarts dies with the old process. The worker re-registers under the same id on a new stream and its heartbeats stop listing the job, but nothing ended the pending execution: the dispatcher kept waiting and held the executor slot until the attempt's execution timeout. Each pending execution now records the stream it went out on. An itemized heartbeat from a newer stream of that worker that leaves the job out twice in a row fails it through the expire path, so the dispatch returns, the slot is released and the retry machinery takes over. Jobs on the heartbeat's own stream, jobs the new stream still lists, and heartbeats that count slots without itemizing them are left alone. Claude-Session: https://claude.ai/code/session_011UpvafcfUuC2mLxNAXLQJi * admin/plugin: let a partly itemized listing clear a dispatch's misses A heartbeat that counted more slots than it itemized returned before the listed jobs had their misses reset, so an omission, a partial heartbeat listing the job, and another omission failed a job the worker was still running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: look up the worker's stream before tracking the attempt A dispatch to a worker with no stream returned after the job was already recorded as assigned, and that record kept new proposals with the same dedupe key out until the stale-job sweep expired it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: fail the attempt whose request could not be sent The dispatch now sends on the stream it looked up before tracking the attempt, so a worker that reconnects in between makes the send fail. That returned with the job still tracked as assigned, and with the worker back nothing closed the record for the 24h stale timeout while its dedupe key kept new proposals out. The attempt is now completed as failed, after it is unregistered so the completion does not wait on a channel nobody reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: leave a send failure to the expiry that already claimed it The send-error path and an orphan expiry could both complete the same attempt and record two failed runs for it. The send-error path now completes the attempt only if no expiry has marked it failed, decided under the same lock that unregisters it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: record a send failure whose entry Shutdown already removed Shutdown closes shutdownCh before it unregisters pending dispatches, so a blocked send returns while its map entry is gone. Read the expiry claim from the dispatch's own state instead of the map lookup, so the attempt is still failed and does not stay assigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: match a padded job id against its trimmed listing Heartbeat work ids are trimmed before the orphan check, so compare the dispatch's job id trimmed too; otherwise a job id with surrounding spaces never matches its own listing and the running job is failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/plugin: skip orphan misses once a completion was handed over The buffer length only shows a completion the dispatcher has not taken yet; after it takes one, the attempt stays registered until the dispatch returns. Mark the hand-off under the pending lock and check that flag instead, so heartbeats in that gap cannot fail a finished attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |