View | Details | Raw Unified | Return to bug 35819
Collapse All | Expand All

(-)a/misc/workers/background_jobs_worker.pl (-3 / +24 lines)
Lines 73-78 my $max_processes = $ENV{MAX_PROCESSES}; Link Here
73
$max_processes ||= C4::Context->config('background_jobs_worker')->{max_processes} if C4::Context->config('background_jobs_worker');
73
$max_processes ||= C4::Context->config('background_jobs_worker')->{max_processes} if C4::Context->config('background_jobs_worker');
74
$max_processes ||= 1;
74
$max_processes ||= 1;
75
75
76
my $not_found_retries = {};
77
my $max_retries = $ENV{MAX_RETRIES} || 10;
78
76
GetOptions(
79
GetOptions(
77
    'm|max-processes=i' => \$max_processes,
80
    'm|max-processes=i' => \$max_processes,
78
    'h|help' => \$help,
81
    'h|help' => \$help,
Lines 130-139 while (1) { Link Here
130
            next;
133
            next;
131
        }
134
        }
132
135
133
        my $job = Koha::BackgroundJobs->search( { id => $args->{job_id}, status => 'new' } )->next;
136
        my $job = Koha::BackgroundJobs->find( $args->{job_id} );
137
138
        if ( $job && $job->status ne 'new' ) {
139
            Koha::Logger->get( { interface => 'worker' } )
140
                ->warn( sprintf "Job %s has wrong status %s", $args->{job_id}, $job->status );
141
142
            # nack without requeue, we do not want to process this frame again
143
            $conn->nack( { frame => $frame, requeue => 'false' } );
144
            next;
145
        }
146
134
        unless ($job) {
147
        unless ($job) {
148
            if ( ++$not_found_retries->{$args->{job_id}} >= $max_retries ) {
149
                Koha::Logger->get( { interface => 'worker' } )
150
                    ->warn( sprintf "Job %s not found, no more retry", $args->{job_id} );
151
152
                # nack without requeue, we do not want to process this frame again
153
                $conn->nack( { frame => $frame, requeue => 'false' } );
154
                next;
155
            }
156
135
            Koha::Logger->get( { interface => 'worker' } )
157
            Koha::Logger->get( { interface => 'worker' } )
136
                ->warn( sprintf "Job %s not found, or has wrong status", $args->{job_id} );
158
                ->debug( sprintf "Job %s not found, will retry later", $args->{job_id} );
137
159
138
            # nack to force requeue
160
            # nack to force requeue
139
            $conn->nack( { frame => $frame, requeue => 'true' } );
161
            $conn->nack( { frame => $frame, requeue => 'true' } );
140
- 

Return to bug 35819