fix
This commit is contained in:
+10
-10
@@ -161,16 +161,16 @@ func main() {
|
||||
log.Printf("worker WARNING: ALLOW_INSECURE_LOCAL_PRODUCTION=1 with loopback WEB_ORIGIN=%s — not for public deploy", cfg.WebOrigin)
|
||||
}
|
||||
|
||||
// Before claiming a fresh heartbeat, reclaim running orphans left by a prior
|
||||
// crash/SIGTERM (ClaimNext only selects pending). Skip when another worker is live.
|
||||
// This process cannot resume prior in-memory work. Always reclaim running
|
||||
// orphans before touching heartbeat so a fast restart (deploy/rb within the
|
||||
// heartbeat stale window) does not leave ClaimNext-invisible status=running
|
||||
// jobs. Single-worker architecture only — never run two processing workers.
|
||||
probe := jobs.ProbeWorkerReadiness(ctx, pool, jobs.DefaultHeartbeatStaleAfter)
|
||||
if probe.WorkerCheck == "missing" || probe.WorkerCheck == "stale" {
|
||||
if res, err := processing.ReclaimOrphanedRunning(ctx, pool); err != nil {
|
||||
log.Printf("worker orphan reclaim: %v", err)
|
||||
} else if res.JobsRequeued > 0 || res.ProductsReset > 0 || res.SyncJobsRequeued > 0 {
|
||||
log.Printf("worker orphan reclaim jobs_requeued=%d products_reset=%d sync_requeued=%d (prior worker %s)",
|
||||
res.JobsRequeued, res.ProductsReset, res.SyncJobsRequeued, probe.WorkerCheck)
|
||||
}
|
||||
if res, err := processing.ReclaimOrphanedRunning(ctx, pool); err != nil {
|
||||
log.Printf("worker orphan reclaim: %v", err)
|
||||
} else if res.JobsRequeued > 0 || res.ProductsReset > 0 || res.SyncJobsRequeued > 0 {
|
||||
log.Printf("worker orphan reclaim jobs_requeued=%d products_reset=%d sync_requeued=%d (heartbeat was %s)",
|
||||
res.JobsRequeued, res.ProductsReset, res.SyncJobsRequeued, probe.WorkerCheck)
|
||||
}
|
||||
|
||||
if err := jobs.TouchHeartbeat(ctx, pool, jobs.ProcessingWorkerID); err != nil {
|
||||
@@ -224,7 +224,7 @@ func main() {
|
||||
log.Printf("support auto AI jobs processed=%d", n)
|
||||
}
|
||||
if _, err := jobSlots.Fill(ctx, pipeline.ClaimNext, func(jobCtx context.Context, jobID uuid.UUID) error {
|
||||
log.Printf("processing job %s", jobID)
|
||||
log.Printf("processing: claimed job=%s", jobID)
|
||||
return pipeline.ProcessJob(jobCtx, jobID)
|
||||
}, markJobFailed); err != nil && !errors.Is(err, pgx.ErrNoRows) {
|
||||
log.Printf("claim error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user