Single mv Command Fixes Duplicate Job Processing in Automated launchd Queue System
A developer running an automated business system discovered a critical race condition after a full-day Codex outage on September 17, 2026, caused by usage limits being exceeded. During the outage, 57 unprocessed JSON files accumulated across three workflows, and when Codex recovered, five launchd lanes fired simultaneously, causing one file to be processed four times within a minute. The root cause was that launchd, acting purely as a scheduler, has no built-in mutual exclusion, leaving multiple processes free to grab the same queued file at once. A non-atomic 'check-then-act' lock file approach proved insufficient, as the race condition could still occur between the check and the act steps. The solution involved using a single atomic mv command to claim files before processing, making the queue pickup script inherently idempotent and eliminating duplicate runs regardless of how many lanes fire at once.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in