Bugzilla – Attachment 179215 Details for
Bug 34070
background_jobs_worker.pl floods logs when it gets error frames
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34070: Add error handling for ERROR frames for background worker
Bug-34070-Add-error-handling-for-ERROR-frames-for-.patch (text/plain), 3.29 KB, created by
Jonathan Druart
on 2025-03-12 15:23:23 UTC
(
hide
)
Description:
Bug 34070: Add error handling for ERROR frames for background worker
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-03-12 15:23:23 UTC
Size:
3.29 KB
patch
obsolete
>From d7a552bd9cecc5e72ce96bdd96692f1918d5b992 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 7 Mar 2025 01:43:25 +0000 >Subject: [PATCH] Bug 34070: Add error handling for ERROR frames for background > worker > >This change adds error handling for ERROR frames to background_jobs_worker.pl. >A previous patch added it to es_indexer_daemon.pl which is a different >background jobs worker. > >To test ERROR handling for background_jobs_worker.pl: >1. Change your RabbitMQ connection details in koha-conf.xml or the hard-coded ones in Koha/BackgroundJob.pm >to include an invalid password. For example, if you don't have a message_broker already defined, use the following: ><message_broker> > <password>bad</password> ></message_broker> >2. sudo koha-worker --restart --quiet kohadev >3. View the errors in the logs: >tail -f /var/log/koha/kohadev/worker-output.log >tail -f /var/log/koha/kohadev/worker-error.log > >To test MESSAGE handling for background_jobs_worker.pl: >1. Ensure RabbitMQ connection details are correct >2. Go to Batch item modification and add the following barcodes: >39999000001310 >39999000004571 >3. Add a z - Public Note of the following and click Save: >THEBACKGROUNDWORKERWORKED >4. Search the catalogue using THEBACKGROUNDWORKERWORKED in the top >catalogue search >5. Note that you get 2 results in your search >6. Look in the logs just to make sure there are no new messages there > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > misc/workers/background_jobs_worker.pl | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > >diff --git a/misc/workers/background_jobs_worker.pl b/misc/workers/background_jobs_worker.pl >index f070c3cf642..5958f70fd2f 100755 >--- a/misc/workers/background_jobs_worker.pl >+++ b/misc/workers/background_jobs_worker.pl >@@ -124,8 +124,27 @@ while (1) { > } > > my $args = try { >- my $body = $frame->body; >- decode_json($body); # TODO Should this be from_json? Check utf8 flag. >+ my $command = $frame->command; >+ my $body = $frame->body; >+ my $content_type = $frame->content_type; >+ if ( $command && $command eq 'MESSAGE' ) { >+ if ( $content_type && $content_type eq 'application/json' ) { >+ decode_json($body); # TODO Should this be from_json? Check utf8 flag. >+ } else { >+ >+ #TODO: This is a fallback for older enqueued messages which are missing the content-type header >+ #TODO: Please replace this decode with a die in the future once content-type is well established >+ decode_json($body); # TODO Should this be from_json? Check utf8 flag. >+ } >+ } elsif ( $command && $command eq 'ERROR' ) { >+ >+ #Known errors: >+ #You must log in using CONNECT first >+ #"NACK" must include a valid "message-id" header >+ Koha::Logger->get( { interface => 'worker' } ) >+ ->warn( sprintf "Shutting down after receiving ERROR frame:\n%s\n", $frame->as_string ); >+ exit 1; >+ } > } catch { > Koha::Logger->get( { interface => 'worker' } )->warn( sprintf "Frame not processed - %s", $_ ); > return; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34070
:
178068
|
179024
|
179025
|
179094
|
179095
|
179214
|
179215
|
179216
|
179217
|
179218
|
182570
|
182571
|
182572
|
182573
|
182574