One Line of mv Kills the 4x Duplicate Run After Recovery: Making launchd Queue Processing Idempotent
说明与用途
使用单个原子 mv 操作消除 launchd 调度队列中的竞争条件,确保每个 JSON 文件仅被处理一次。
问题
Multiple launchd lanes processed the same JSON files concurrently after a service outage, causing duplicate work and data corruption.
结果
The atomic mv approach eliminated duplicate processing, ensuring idempotent queue handling and preventing data corruption after outages.
工作流
- 1. Define DONE_DIR and PROCESSING_DIR variables.
2. Create PROCESSING_DIR if it doesn't exist.
3. For each JSON file in DONE_DIR:
a. Attempt
mv "$file" "$PROCESSING_DIR/$(basename "$file")". b. If mv succeeds, process the file. c. If mv fails (file already moved), skip to next file. 4. Continue with existing processing logic on the moved file.
证据
Exactly one succeeds and the other is guaranteed to fail.
launchd simply invokes run-codex-funnel.sh according to this schedule.
- 记录日期: 2026-09-22T09:00:29.229Z