Hacker News new | ask | show | jobs
by throwaway74567 1160 days ago
That's a good approach if the worker is connected to the database.

If an external process is responsible for marking a job as done, you could add a timestamp column that will act as a timeout. The column will be updated before the job is given to the worker.

SELECT ... WHERE ts > NOW()

UPDATE ... SET ts = NOW() + INTERVAL '1 HOUR'