PromptBase
PromptBase SelectGet Select
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Skill Details

Runtime
(gpt-5.6)
Example user message
[userMessage]: Our NestJS image workers leave jobs stuck after crashes, and sometimes an old worker finishes after another worker takes over.
Example agent response
Project Detected: NestJS TypeScript workers using PostgreSQL, BullMQ, S3-compatible storage, and multiple Kubernetes replicas --- Lease Failure Found: - Jobs are marked processing by a non-atomic read followed by update, and processing has no expiration - Affected job: Image conversion - Current ownership mechanism: Worker hostname stored without a lease or version --- Lease Contract: - Job identity: Stable image_job UUID - Owner identity: Worker-instance UUID generated at process start - Lease duration: 90 seconds - Heartbeat interval: 20 seconds - Fencing token: Monotonic lease_version - Takeover condition: Running job has an expired lease and remaining attempts --- Repair Applied: - Claim behavior: Added one conditional PostgreSQL claim that assigns owner, expiration, attempt, and incremented lease version - Renewal behavior: Heartbeats extend only the matching owner and lease version - Stale-worker protection: Progress, output publication, failure, and completion writes require the current fencing token - Recovery behavior: Replacement workers resume after the last committed conversion stage and publish output through a fenced finalization step --- Files Modified: - src/jobs/image-job.entity.ts - src/jobs/image-job.repository.ts - src/workers/image.worker.ts - src/workers/job-heartbeat.ts - src/storage/image-output.service.ts - migrations/add-image-job-leases.ts - test/image-job-lease-recovery.spec.ts --- Commands Executed: - npm run typecheck - npm test -- image-job-lease-recovery.spec.ts - npm run build - npm run migration:show --- Contention Test: - Competing workers: 25 - Successful owners: 1 - Duplicate owners: 0 --- Crash Recovery Test: - Crash point: Worker terminated after completing conversion stage 2 of 4 - Lease recovery: Replacement worker claimed the job after lease expiration - Work resumed from: Last committed stage 2 checkpoint - Lost work: 0 completed stages --- Stale Worker Test: - Old token: 17 - New token: 18 - Stale writes accepted: 0 - Final owner result: Worker with token 18 published one output and completed the job --- Validation Result: Type checking, migration inspection, 27 lease and crash-recovery tests, and the production build completed successfully using isolated PostgreSQL, BullMQ, and storage fixtures. --- Remaining Risks: - Production object-storage overwrite and consistency behavior requires staging verification.
OpenClaw Skill

Repair Stuck Job Leases

Add to Cart
PromptBase Select
Get this skill + 9 more with Select$14 your first month, then $19/mo$14 first month, then $19/mo
View Select
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this skill, you agree to our terms of service
GPT-5.6
Tested icon
Guide icon
Free credits icon
Repair workers that leave jobs stuck, process the same task twice, or let expired owners write results. This skill traces claims, leases, heartbeats, timeouts, and completion writes. It adds bounded leases, fencing tokens, safe takeover, orphan recovery, and crash tests. ✔ Recover abandoned jobs ✔ Block stale workers ✔ Prevent duplicate completion Ideal for queues, schedulers, imports, and distributed workers.
...more
Added over 1 month ago
Report
Browse Marketplace