2

In Beanstalkd, when a job hits TTR it will kill the worker handling the job and release the job back into the pool. In our system, this should be a super-rare event, and in that case I would like to just bury the job instead.

How would one go about doing this?

(If it matters, we are using PHP + Pheanstalk)

DOOManiac
  • 6,066
  • 8
  • 44
  • 67

1 Answers1

2

It sounds to me that you didn't implemented the protocol properly. You need to handle DEADLINE_SOON, and do TOUCH.

What does DEADLINE_SOON mean?

DEADLINE_SOON is a response to a reserve command indicating that you have a job reserved whose deadline is real soon (current safety margin is approximately 1 second).

If you are frequently receiving DEADLINE_SOON errors on reserve, you should probably consider increasing the TTR on your jobs as it generally indicates you aren’t completing them in time. It may also be that you are failing to delete tasks when you have completed them.

See the mailing list discussion for more information.

How does TTR work?

TTR only applies to a job at the moment it becomes reserved. At that event, a timer (called “time-left” in the job stats) starts counting down from the job’s TTR.

  • If the timer reaches zero, the job gets put back in the ready queue.
  • If the job is buried, deleted, or released before the timer runs out, the timer ceases to exist.
  • If the job is touch"ed before the timer reaches zero, the timer starts over counting down from TTR.

The "touch" command

Allows a worker to request more time to work on a job. This is useful for jobs that potentially take a long time, but you still want the benefits of a TTR pulling a job away from an unresponsive worker. A worker may periodically tell the server that it's still alive and processing a job (e.g. it may do this on DEADLINE_SOON). The command postpones the auto release of a reserved job until TTR seconds from when the command is issued.

Pentium10
  • 204,586
  • 122
  • 423
  • 502
  • I'm not implementing the protocol myself, but rather using [Pheanstalk](https://github.com/pda/pheanstalk), a popular PHP framework for Beanstalkd. Unfortunately it's a little light on documentation, so I'm not sure how to handle `DEADLINE_SOON` in my own code. I will take a look at `touch()` however. Thanks! – DOOManiac Nov 10 '14 at 20:55
  • Implementing the protocol means to follow the protocol. So you need to find out how to read DEADLINE_SOON with Pheanstalk. – Pentium10 Nov 10 '14 at 22:09
  • I was never able to find anything more on `DEADLINE_SOON`, but I was able to solve my problem by calling `touch()` appropriately. Thanks! – DOOManiac Nov 11 '14 at 21:49