mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-04 07:07:18 +00:00
fix: use lifecycle context for job-type budget and retry backoff
- Use r.ctx (cancelled on shutdown) as parent for per-job-type budget context instead of context.Background(), so in-flight work is cancelled promptly on plugin shutdown. - Replace waitForShutdownOrTimer with waitForShutdownOrCtx in retry backoff so retries respect the per-job-type budget context. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e0cccae794
commit
05902c7101
@@ -194,7 +194,7 @@ func (r *Plugin) runJobTypeIteration(
|
||||
if budget <= 0 {
|
||||
budget = defaultMaxJobTypeDuration
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), budget)
|
||||
ctx, cancel := context.WithTimeout(r.ctx, budget)
|
||||
defer cancel()
|
||||
|
||||
start := time.Now().UTC()
|
||||
@@ -750,8 +750,8 @@ func (r *Plugin) executeScheduledJobWithExecutor(
|
||||
Stage: "retry",
|
||||
OccurredAt: timeToPtr(time.Now().UTC()),
|
||||
})
|
||||
if !waitForShutdownOrTimer(r.shutdownCh, policy.RetryBackoff) {
|
||||
return fmt.Errorf("plugin is shutting down")
|
||||
if !waitForShutdownOrCtx(r.shutdownCh, parentCtx, policy.RetryBackoff) {
|
||||
return fmt.Errorf("plugin is shutting down or context canceled")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user