Skip to content

Job queue: no row-level claim / not multi-instance safe #26

Description

@lisiur

The scheduler re-queues every due PENDING job and there is no atomic "claim" when moving to PROCESSING (lib/queues/job-worker.ts:22). Multiple API instances will duplicate-execute.

Fix: Add SELECT … FOR UPDATE SKIP LOCKED or a conditional updateMany on status = 'PENDING' before processing. See ARCHITECTURE.md §8.

Deferred: The service runs in-process inside Next.js as a single long-lived process by design (ARCHITECTURE.md §8), so no duplicate execution occurs today. This only bites if the API is horizontally scaled — PM2/Node cluster mode, rolling or blue-green deploys with overlap, Docker replicas > 1, or Next.js standalone with multiple workers — none of which are on the roadmap. Revisit when multi-instance deployment is actually planned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions