How Solid Queue uses a semaphore
Solid Queue’s limits_concurrency keeps a semaphore as a database row. I traced it through the 1.4.0 source: blocked jobs wait as rows in a table instead of holding a worker thread, a permit is taken when the job is admitted to the ready queue (not when it starts running), and permits expire. The row doesn’t record which job holds a permit. So a job that runs past its duration can, when it finishes, send a late signal that lets two other jobs overlap under a limit of one. A small script reproduces it. The post ends with how to size duration and why concurrency limits don’t replace protection at the write: How Solid Queue uses a semaphore.
Post a comment