gearmand, the server, includes an important feature that should be enabled for all installations:
This feature protects against poison messages/jobs which is not enabled by default.
Poison Message: A message in the queue that has met the threshold of allowable retries.For Gearman, this would be when a worker receives a job but disconnects from the server without advising the job's completion whether success or failure.
A disconnect can occur due to an error in the worker's processing of a job such as "out of memory", an error in the processing such as a "Segmentation fault" when resizing an image, or even an error in the Gearman PHP extension.
Now why is this important?Let's run a scenario:
- Worker connects to gearmand
- Worker receives job
- Worker begins processing job
- Worker dies due to an error and disconnects
- Gearmand sesnses disconnect
- Gearmand redispatches job to another worker
- Lather, rinse, repeat until all workers crash
What if I want to handle that deleted job?
(for example, emailing the client that their job failed)
Unfortunately, currently, you will have to scan the log looking for deleted jobs and manually handle them.
However, aligned with Ender Tech's open source commitment, I have submitted a feature request to have the message redispatched to a "Dead Letter Queue" or "Poison Queue":
This way you can assign a worker to handle the dead jobs without scanning the log thereby allowing a fast, robust, and consistent job handling infrastructure.