This issue applies to 7.x-2.x, 7.x-1.x, and 6.x-1.x.

The current BeanstalkdQueue::claimItem() implementation takes an argument that it describes as "$lease_time", and the phpdoc indicates that this argument controls the length of time the job will run prior to beanstalkd assuming that the worker has failed and pulling the job back into the queue for consumption by another worker. Now, there's a bug in all versions where this parameter isn't actually passed to pheanstalk, dating back to this commit; instead, it's hardcoded to pass 0.

Thing is though, that argument that's being passed isn't a lease time (what beanstalkd refers to as time to run, or TTR). TTR is controlled by the job producer, which is clear from the previous doc link (it's a param to put). The docs about reserve are a little confusingly worded, though, and may seem to leave open the possibility that the timeout val controls both TTR and the reserve timeout. If there's any doubt, have a look at this discussion, which shows (nicely, with pheanstalk AND reserve(0) calls) in the gdb dump of the server how the ttr for the claimed job is set to 60000000.

The actual function of the value passed to reserve (in fact, reserve-with-timeout) is to determine how long the beanstalkd server should make the worker block before releasing it with no job (if a job is not found in that time period). Pheanstalk's implementation uses NULL to indicate that no value should be passed (as the default value), which should also be the default value for this module's implementation of claimItem().

The attached patch changes the default value to NULL, ensures the param is passed to Pheanstalk, changes the name of the param and updates the phpdoc accordingly. It should be applied to all branches, though I only know that it applies easily to the 7.x-1.x branch.

CommentFileSizeAuthor
#6 2496115-drupalorg-rc3.diff814 bytesdrumm
reserve-timeout.patch2.05 KBsdboyer

Comments

sdboyer’s picture

Issue summary: View changes
sdboyer’s picture

Issue summary: View changes

i know html

sdboyer’s picture

Issue summary: View changes
sdboyer’s picture

Issue summary: View changes
drumm’s picture

Issue tags: +affects drupal.org
drumm’s picture

StatusFileSize
new814 bytes

reserve-timeout.patch doesn't apply against 1.0-rc3, which we are running on Drupal.org. The first comment-only chunk is rejected. Attached is a patch that applies for us.

drumm’s picture

Status: Needs review » Reviewed & tested by the community

This is working well.

mlhess’s picture

Issue summary: View changes

  • gordon committed 716344f on 7.x-1.x authored by sdboyer
    Issue #2496115 by sdboyer, drumm: claimItem() "$lease_time" argument is...

  • gordon committed e5efde8 on 7.x-2.x authored by sdboyer
    Issue #2496115 by sdboyer, drumm: claimItem() "$lease_time" argument is...

  • gordon committed a036824 on 6.x-1.x authored by sdboyer
    Issue #2496115 by sdboyer, drumm: claimItem() "$lease_time" argument is...
gordon’s picture

Status: Reviewed & tested by the community » Fixed

This has been applied to 6.x-1.x, 7.x-1.x and 7.x-2.x

  • gordon committed e5efde8 on 8.x-1.x authored by sdboyer
    Issue #2496115 by sdboyer, drumm: claimItem() "$lease_time" argument is...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.