Oct 26, 2022
My solution to the semaphore locking problem is another status column indicating whether a step has executed. For completeness you need three states: ready (the default), running, and complete. The state transitions from ready to running via an update statement WHERE status=running. Return immediately if that update statement fails to update a row. When you use persistent storage for locking, you must code for the dead worker problem where the worker that set the status to running dies and never updates the status again. Fortunately there are supervisors.