Bug#611355: libgearman-client-perl: Programming error prevents Gearman::Worker::work() from connecting to servers

Richard Wallman richard at wallman.org.uk
Fri Jan 28 12:46:36 UTC 2011


Package: libgearman-client-perl
Version: 1.11-1
Severity: important
Tags: patch upstream

Gearman::Worker v1.10 introduced a random server selection feature,
to stop all the workers from hitting the same Gearman server. It appears
that this check has an issue that causes it to consider *every* server
inactive, and so no jobs can be processed.

On line 281, a call to _get_js_sock is made, with a single parameter -
the name of a server.

On line 132 (inside _get_js_sock), the parameters are parsed, and an
option "on_connect" is assigned to a local variable. The call from
work() doesn't contain any options, so this is set to undef.

This becomes significant on line 174, where the socket is checked for
validity before being cached and returned. Because $on_connect is undef,
this condition will *always* trigger the following code block, removing
the socket from the cache and returning empty-handed.

Upon return to work(), this undef value causes the loop to go through the
rest of the configured servers, failing each time. No jobs get processed.



There is a "proper" call to _get_js_sock  on line 388 - this includes
a value for on_connect, and so it allows the "inactive" servers to be
rechecked on the next iteration of work(). Unfortunately, this next
iteration will just set the servers "inactive" again.

The fix (appears) to be quite simple - change line 281 from:

my $jss = $self->_get_js_sock($js)

to

my $jss = $self->_get_js_sock($js, on_connect => sub{return Gearman::Util::send_req($_[0], \$presleep_req)} )

This adds the missing on_connect option, with the same subroutine that's
defined on line 383. (More "invasive" would be to move that declaration
to the top and use the same call format as line 388)

-- System Information:
Debian Release: 6.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-xen-686 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF8, LC_CTYPE=en_GB.UTF8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libgearman-client-perl depends on:
pn  libstring-crc32-perl          <none>     (no description available)
ii  perl                          5.10.1-17  Larry Wall's Practical Extraction 

libgearman-client-perl recommends no packages.

libgearman-client-perl suggests no packages.





More information about the pkg-perl-maintainers mailing list