t1478: fix(pulse-wrapper): add flock-based lock guard to prevent concurrent instances#4454
Conversation
…instances (GH#4409) 14 concurrent pulse instances ran simultaneously, each spawning workers before the previous pulse could assess running workers, resulting in 52 active workers against a 24-slot pool. Root cause: check_dedup() uses a PID file with a TOCTOU race window — between reading the PID file and writing the new PID, another instance can pass the same check. Fix: Add flock(1) -n (non-blocking) as the primary instance lock in main(), acquired before any other check. flock is atomic at the kernel level — no race window. The lock auto-releases on process exit (including crashes, OOM kills, SIGKILL). Falls back gracefully to PID-based dedup on systems without flock (e.g., macOS).
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Caution Review failedPull request was closed or merged during review WalkthroughThe change introduces a robust flock-based instance locking mechanism to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Mar 13 18:13:35 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|



Summary
Fixes concurrent pulse supervisor instances running simultaneously.
Closes #4452
Summary by CodeRabbit