kr/beanstalkd — pull request #174 by qualtrics (2013-02-28 23:53:02+00:00)
Title: set pending timeout to -1 once a job is reserved

Today we found a bug where the pending timeout on a connection can conflict with the TTR of a reserved job.

Steps to reproduce:
1. Put a job will a TTR of 10s.
2. With a client reserve a job with a timeout of 5s.
2.a. The job should be immediately reserved and given to the client.
3. Sleep for 15s in the client.
4. Close the connection

Result:
The job's TTR doesn't expire and is not released to the ready queue until after 15s, when the connection closes.
We dug in to the code and what we found that the connection still had a pending_timeout value set for ~5s in the future. After 5s passed the connection would 'tick' and then not be rescheduled because there were no expiring jobs. It then would no longer 'tick' until the client either used or closed the connection.

Expected Result:
The job TTR expires and is released after 10s.

Fix:
The fix is to set the pending_timeout equal to -1 in the reserve job function. This feels like both a safe and correct change because if the connection has a reserved job it should no longer have a pending timeout.