Fix an edge case that bit me a few times when this was in my own app.
Make sure that locking the bare PG connection is reentrant.
Make sure that the same connection is used throughout locking a job, working it, and releasing the lock.