Hello community, here is the log from the commit of package perl-Minion for openSUSE:Factory checked in at 2020-07-15 15:05:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Minion (Old) and /work/SRC/openSUSE:Factory/.perl-Minion.new.3060 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Minion" Wed Jul 15 15:05:11 2020 rev:59 rq:820835 version:10.10 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Minion/perl-Minion.changes 2020-07-14 07:58:38.161662662 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Minion.new.3060/perl-Minion.changes 2020-07-15 15:05:44.815452569 +0200 @@ -1,0 +2,11 @@ +Sun Jul 12 03:08:33 UTC 2020 - Tina Müller <[email protected]> + +- updated to 10.10 + see /usr/share/doc/packages/perl-Minion/Changes + + 10.10 2020-07-11 + - Added stuck_after attribute to Minion. + - Improved repair method in Minion::Backend::Pg to detect stuck jobs and transtion them to the failed state after 2 + days of inactivity. + +------------------------------------------------------------------- Old: ---- Minion-10.09.tar.gz New: ---- Minion-10.10.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Minion.spec ++++++ --- /var/tmp/diff_new_pack.wA351d/_old 2020-07-15 15:05:46.927454629 +0200 +++ /var/tmp/diff_new_pack.wA351d/_new 2020-07-15 15:05:46.931454633 +0200 @@ -17,7 +17,7 @@ Name: perl-Minion -Version: 10.09 +Version: 10.10 Release: 0 %define cpan_name Minion Summary: Job queue ++++++ Minion-10.09.tar.gz -> Minion-10.10.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-10.09/Changes new/Minion-10.10/Changes --- old/Minion-10.09/Changes 2020-07-09 14:42:09.000000000 +0200 +++ new/Minion-10.10/Changes 2020-07-11 19:49:32.000000000 +0200 @@ -1,4 +1,9 @@ +10.10 2020-07-11 + - Added stuck_after attribute to Minion. + - Improved repair method in Minion::Backend::Pg to detect stuck jobs and transtion them to the failed state after 2 + days of inactivity. + 10.09 2020-07-09 - Added EXPERIMENTAL support for job sequences. - Added EXPERIMENTAL sequence option to enqueue method in Minion, Minion::Backend and Minion::Backend::Pg. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-10.09/META.json new/Minion-10.10/META.json --- old/Minion-10.09/META.json 2020-07-09 20:31:27.000000000 +0200 +++ new/Minion-10.10/META.json 2020-07-11 23:17:51.000000000 +0200 @@ -57,6 +57,6 @@ "web" : "https://webchat.freenode.net/#mojo" } }, - "version" : "10.09", + "version" : "10.10", "x_serialization_backend" : "JSON::PP version 4.05" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-10.09/META.yml new/Minion-10.10/META.yml --- old/Minion-10.09/META.yml 2020-07-09 20:31:27.000000000 +0200 +++ new/Minion-10.10/META.yml 2020-07-11 23:17:51.000000000 +0200 @@ -29,5 +29,5 @@ homepage: https://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/mojolicious/minion.git -version: '10.09' +version: '10.10' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-10.09/lib/Minion/Backend/Pg.pm new/Minion-10.10/lib/Minion/Backend/Pg.pm --- old/Minion-10.09/lib/Minion/Backend/Pg.pm 2020-07-09 16:52:28.000000000 +0200 +++ new/Minion-10.10/lib/Minion/Backend/Pg.pm 2020-07-11 19:46:38.000000000 +0200 @@ -183,12 +183,17 @@ $db->query("delete from minion_workers where notified < now() - interval '1 second' * ?", $minion->missing_after); # Jobs with missing worker (can be retried) - my $fail = $db->query( + $db->query( "select id, retries from minion_jobs as j where state = 'active' and queue != 'minion_foreground' and not exists (select 1 from minion_workers where id = j.worker)" - )->hashes; - $fail->each(sub { $self->fail_job(@$_{qw(id retries)}, 'Worker went away') }); + )->hashes->each(sub { $self->fail_job(@$_{qw(id retries)}, 'Worker went away') }); + + # Jobs in queue without workers or not enough workers (cannot be retried and requires admin attention) + $db->query( + q{update minion_jobs set state = 'failed', result = '"Job appears stuck in queue"' + where state = 'inactive' and delayed + ? * interval '1 second' < now()}, $minion->stuck_after + ); # Old jobs with no unresolved dependencies $db->query( @@ -210,8 +215,7 @@ my ($self, $id, $retries, $options) = (shift, shift, shift, shift || {}); return !!$self->pg->db->query( - "update minion_jobs - set attempts = coalesce(?, attempts), delayed = (now() + (interval '1 second' * ?)), + "update minion_jobs set attempts = coalesce(?, attempts), delayed = (now() + (interval '1 second' * ?)), parents = coalesce(?, parents), priority = coalesce(?, priority), queue = coalesce(?, queue), retried = now(), retries = retries + 1, state = 'inactive' where id = ? and retries = ? @@ -272,8 +276,7 @@ my ($self, $id, $options) = @_; return $self->pg->db->query( - "update minion_jobs - set started = now(), state = 'active', worker = ? + "update minion_jobs set started = now(), state = 'active', worker = ? where id = ( select id from minion_jobs as j where delayed <= now() and id = coalesce(?, id) and (parents = '{}' or not exists ( @@ -292,8 +295,7 @@ my ($self, $fail, $id, $retries, $result) = @_; return undef unless my $row = $self->pg->db->query( - "update minion_jobs - set finished = now(), result = ?, state = ? + "update minion_jobs set finished = now(), result = ?, state = ? where id = ? and retries = ? and state = 'active' returning attempts", {json => $result}, $fail ? 'failed' : 'finished', $id, $retries )->array; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-10.09/lib/Minion.pm new/Minion-10.10/lib/Minion.pm --- old/Minion-10.09/lib/Minion.pm 2020-07-09 14:38:30.000000000 +0200 +++ new/Minion-10.10/lib/Minion.pm 2020-07-11 19:45:39.000000000 +0200 @@ -15,12 +15,12 @@ has app => sub { $_[0]{app_ref} = Mojo::Server->new->build_app('Mojo::HelloWorld') }, weak => 1; has 'backend'; -has backoff => sub { \&_backoff }; -has missing_after => 1800; -has remove_after => 172800; -has tasks => sub { {} }; +has backoff => sub { \&_backoff }; +has missing_after => 1800; +has [qw(remove_after stuck_after)] => 172800; +has tasks => sub { {} }; -our $VERSION = '10.09'; +our $VERSION = '10.10'; sub add_task { my ($self, $name, $task) = @_; @@ -432,6 +432,14 @@ will be removed automatically by L</"repair">, defaults to C<172800> (2 days). It is not recommended to set this value below 2 days. +=head2 stuck_after + + my $after = $minion->stuck_after; + $minion = $minion->stuck_after(86400); + +Amount of time in seconds after which jobs that have not been processed will be considered stuck by L</"repair"> and +transition to the C<failed> state, defaults to C<172800> (2 days). + =head2 tasks my $tasks = $minion->tasks; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-10.09/t/pg.t new/Minion-10.10/t/pg.t --- old/Minion-10.09/t/pg.t 2020-07-09 14:34:19.000000000 +0200 +++ new/Minion-10.10/t/pg.t 2020-07-11 20:54:52.000000000 +0200 @@ -149,6 +149,7 @@ }; subtest 'Repair old jobs' => sub { + is $minion->remove_after, 172800, 'right default'; my $worker = $minion->worker->register; my $id = $minion->enqueue('test'); my $id2 = $minion->enqueue('test'); @@ -175,6 +176,33 @@ ok !$minion->job($id3), 'job has been cleaned up'; }; +subtest 'Repair stuck jobs' => sub { + is $minion->stuck_after, 172800, 'right default'; + my $worker = $minion->worker->register; + my $id = $minion->enqueue('test'); + my $id2 = $minion->enqueue('test'); + my $id3 = $minion->enqueue('test'); + my $id4 = $minion->enqueue('test'); + $minion->backend->pg->db->query("update minion_jobs set delayed = now() - ? * interval '1 second' where id = ?", + $minion->stuck_after + 1, $_) + for $id, $id2, $id3, $id4; + ok $worker->dequeue(0, {id => $id4})->finish('Works!'), 'job finished'; + my $job2 = $worker->dequeue(0, {id => $id2}); + $minion->repair; + is $job2->info->{state}, 'active', 'job is still active'; + ok $job2->finish, 'job finished'; + my $job = $minion->job($id); + is $job->info->{state}, 'failed', 'job is no longer active'; + is $job->info->{result}, 'Job appears stuck in queue', 'right result'; + my $job3 = $minion->job($id3); + is $job3->info->{state}, 'failed', 'job is no longer active'; + is $job3->info->{result}, 'Job appears stuck in queue', 'right result'; + my $job4 = $minion->job($id4); + is $job4->info->{state}, 'finished', 'job is still finished'; + is $job4->info->{result}, 'Works!', 'right result'; + $worker->unregister; +}; + subtest 'List workers' => sub { my $worker = $minion->worker->register; my $worker2 = $minion->worker->status({whatever => 'works!'})->register;
