Bugzilla – Attachment 102804 Details for
Bug 23571
Add measures to prevent concurrent execution of fines.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23571: Prevent concurrent execution of fines.pl
Bug-23571-Prevent-concurrent-execution-of-finespl.patch (text/plain), 1.87 KB, created by
Jonathan Druart
on 2020-04-13 10:10:17 UTC
(
hide
)
Description:
Bug 23571: Prevent concurrent execution of fines.pl
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-13 10:10:17 UTC
Size:
1.87 KB
patch
obsolete
>From 3b89a3431530d38934e0cab6b37fb76901cb4131 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Sun, 12 Apr 2020 10:27:57 -0300 >Subject: [PATCH] Bug 23571: Prevent concurrent execution of fines.pl > >This patch introduces locking in fines.pl. It does so by leveraging on >bug 25109, which introduces a generic locking implementation on >Koha::Script. > >The introduced changes: >1. Try to get the lock >2.a. If success, normal execution happens >2.b. If rejected, cronlogaction is called with a meaningful message and > a normal exit happens, so we don't flood the logs in vain. --verbose > will make the script print the same message on STDERR, as already is > the case with this script > >To test: >1. Apply this patch >2. In two separate consoles run: > $ kshell > k$ perl misc/cronjobs/fines.pl --verbose >SUCCESS => The first one runs normally, the second one exists really fast > and prints a message about the lock. >3. Sign off :-D > >Sponsored-by: Orex Digital > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Amended-pach JD: Fix syntax issue (typo Koha::Scrip and ';' after the >catch block) >--- > misc/cronjobs/fines.pl | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > >diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl >index a5b920a880..9815283838 100755 >--- a/misc/cronjobs/fines.pl >+++ b/misc/cronjobs/fines.pl >@@ -36,6 +36,7 @@ use C4::Overdues; > use Getopt::Long; > use Carp; > use File::Spec; >+use Try::Tiny; > > use Koha::Calendar; > use Koha::DateUtils; >@@ -76,6 +77,24 @@ if ($help) { > exit; > } > >+my $script_handler = Koha::Script->new( >+ { >+ script => $0, >+ use_lock => 1 >+ } >+); >+ >+try { >+ $script_handler->lock_exec; >+} >+catch { >+ my $message = "Skipping execution of $0 ($_)"; >+ print STDERR $message >+ if $verbose; >+ cronlogaction( $message ); >+ exit; >+}; >+ > cronlogaction(); > > my @borrower_fields = >-- >2.20.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 23571
:
96055
|
96056
|
98898
|
98899
|
99263
|
99264
|
99265
|
102772
|
102804
|
102821
|
102844
|
102888
|
102910
|
102911
|
102912