Skip Menu |
 

This queue is for tickets about the TheSchwartz-Moosified CPAN distribution.

Report information
The Basics
Id: 71128
Status: open
Priority: 0/
Queue: TheSchwartz-Moosified

People
Owner: Nobody in particular
Requestors: revmischa [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Priority not respected due to job block shuffling
Download (untitled) / with headers
text/plain 255b
Because the worker grabs a block (50) of jobs at a time and shuffles them, priority gets lost. Needs to re-sort by priority after shuffling. I've temporarily solved this problem in my workers by setting $TheSchwartz::Moosified::FIND_JOB_BATCH_SIZE = 1;
Download (untitled) / with headers
text/plain 603b
On Wed Sep 21 15:18:02 2011, REVMISCHA wrote: Show quoted text
> Because the worker grabs a block (50) of jobs at a time and shuffles > them, priority gets lost. Needs to re-sort by priority after shuffling. > I've temporarily solved this problem in my workers by setting > $TheSchwartz::Moosified::FIND_JOB_BATCH_SIZE = 1;
Hi, Sorry to be dense but I'm not exactly sure how to best reproduce this. Could you provide some steps or a failing unit test and I'll get it fixed? I see in the job finding code that it does prioritize and attempts to query using that, but obviously it seems that isn't working correctly.
Subject: Re: [rt.cpan.org #71128] Priority not respected due to job block shuffling
Date: Thu, 22 Sep 2011 12:00:22 -0700
To: bug-TheSchwartz-Moosified [...] rt.cpan.org
From: Mischa Spiegelmock <mspiegelmock [...] gmail.com>
Download (untitled) / with headers
text/plain 1.2k
I think the problem lies in the first chunk of grab_a_job sub _grab_a_job { my ( $client, $dbh, @jobs ) = @_; ## Got some jobs! Randomize them to avoid contention between workers. @jobs = shuffle(@jobs); It does select by priority, but it selects 50 at a time. If the number of top priority jobs is < 50, it will select other jobs of a lower priority at the same time. Then it shuffles them, so you end up with jobs in a random order. On Thu, Sep 22, 2011 at 11:57 AM, J. Shirley via RT <bug-TheSchwartz-Moosified@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=71128 > > > On Wed Sep 21 15:18:02 2011, REVMISCHA wrote:
>> Because the worker grabs a block (50) of jobs at a time and shuffles >> them, priority gets lost. Needs to re-sort by priority after shuffling. >> I've temporarily solved this problem in my workers by setting >> $TheSchwartz::Moosified::FIND_JOB_BATCH_SIZE = 1;
> > > Hi, > > Sorry to be dense but I'm not exactly sure how to best reproduce this. > Could you provide some steps or a failing unit test and I'll get it fixed? > > I see in the job finding code that it does prioritize and attempts to > query using that, but obviously it seems that isn't working correctly. >
Download (untitled) / with headers
text/plain 1.7k
On Thu Sep 22 15:00:31 2011, mspiegelmock@gmail.com wrote: Show quoted text
> I think the problem lies in the first chunk of grab_a_job > sub _grab_a_job { > my ( $client, $dbh, @jobs ) = @_; > > ## Got some jobs! Randomize them to avoid contention between workers. > @jobs = shuffle(@jobs); > > It does select by priority, but it selects 50 at a time. If the number > of top priority jobs is < 50, it will select other jobs of a lower > priority at the same time. Then it shuffles them, so you end up with > jobs in a random order. > > On Thu, Sep 22, 2011 at 11:57 AM, J. Shirley via RT > <bug-TheSchwartz-Moosified@rt.cpan.org> wrote:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=71128 > > > > > On Wed Sep 21 15:18:02 2011, REVMISCHA wrote:
> >> Because the worker grabs a block (50) of jobs at a time and shuffles > >> them, priority gets lost. Needs to re-sort by priority after shuffling. > >> I've temporarily solved this problem in my workers by setting > >> $TheSchwartz::Moosified::FIND_JOB_BATCH_SIZE = 1;
> > > > > > Hi, > > > > Sorry to be dense but I'm not exactly sure how to best reproduce this. > > Could you provide some steps or a failing unit test and I'll get it
fixed? Show quoted text
> > > > I see in the job finding code that it does prioritize and attempts to > > query using that, but obviously it seems that isn't working correctly. > >
Oh, ok, sorry - I thought you were saying that the expected behavior was broken rather than just not being ideal. If we resort by priority, it's going to be the same order that it was passed into _grab_a_job and then there may be worker contention. I think the fix may be to split them up and only randomize based on priority (that is, don't randomize unless priority is the same). Will that solve your issue?
Subject: Re: [rt.cpan.org #71128] Priority not respected due to job block shuffling
Date: Thu, 22 Sep 2011 14:22:50 -0700
To: bug-TheSchwartz-Moosified [...] rt.cpan.org
From: Mischa Spiegelmock <mspiegelmock [...] gmail.com>
A better solution may be to shuffle, then sort the shuffled jobs by priority. That way they will still be in order of priority, but still randomized a bit. On Thu, Sep 22, 2011 at 12:09 PM, J. Shirley via RT <bug-TheSchwartz-Moosified@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=71128 > > > On Thu Sep 22 15:00:31 2011, mspiegelmock@gmail.com wrote:
>> I think the problem lies in the first chunk of grab_a_job >> sub _grab_a_job { >>     my ( $client, $dbh, @jobs ) = @_; >> >>     ## Got some jobs! Randomize them to avoid contention between workers. >>     @jobs = shuffle(@jobs); >> >> It does select by priority, but it selects 50 at a time. If the number >> of top priority jobs is < 50, it will select other jobs of a lower >> priority at the same time. Then it shuffles them, so you end up with >> jobs in a random order. >> >> On Thu, Sep 22, 2011 at 11:57 AM, J. Shirley via RT >> <bug-TheSchwartz-Moosified@rt.cpan.org> wrote:
>> > <URL: https://rt.cpan.org/Ticket/Display.html?id=71128 > >> > >> > On Wed Sep 21 15:18:02 2011, REVMISCHA wrote:
>> >> Because the worker grabs a block (50) of jobs at a time and shuffles >> >> them, priority gets lost. Needs to re-sort by priority after shuffling. >> >> I've temporarily solved this problem in my workers by setting >> >> $TheSchwartz::Moosified::FIND_JOB_BATCH_SIZE = 1;
>> > >> > >> > Hi, >> > >> > Sorry to be dense but I'm not exactly sure how to best reproduce this. >> > Could you provide some steps or a failing unit test and I'll get it
> fixed?
>> > >> > I see in the job finding code that it does prioritize and attempts to >> > query using that, but obviously it seems that isn't working correctly. >> >
> > Oh, ok, sorry - I thought you were saying that the expected behavior was > broken rather than just not being ideal. > > If we resort by priority, it's going to be the same order that it was > passed into _grab_a_job and then there may be worker contention. > > I think the fix may be to split them up and only randomize based on > priority (that is, don't randomize unless priority is the same). > > Will that solve your issue? > >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.