ryandotsmith/queue_classic — pull request #170 by smathieu (2013-07-21 00:20:51+00:00)
Title: Don't lock jobs indefinitely when worker crashed (#165)

This is related to #165.

This works by spawning a worker thread for each worker that updates a database table with a last_seen timestamp every X seconds. If the worker hasn't checked in a while, we consider the job to be unlocked and allow another worker to process it.

This comes with one major caveat. We cannot use the same PG connection as the worker since it's possible (even likely) that the code being executed will open a transaction. If that's the case, updating the worker table would have no visible effect to other workers until the transaction gets committed.

The workaround is to use a separate connection.

If you can think of a better solution to this problem, I'll be happy to consider it.