[Koha-bugs] [Bug 15529] Process Message Queue may send duplicate emails if process is launched twice

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Oct 4 02:02:05 CEST 2018


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15529

M. Tompsett <mtompset at hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #78918|0                           |1
        is obsolete|                            |

--- Comment #24 from M. Tompsett <mtompset at hotmail.com> ---
Created attachment 79911
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=79911&action=edit
Bug 15529 - Locking process_message_queue.pl cron whilst it is running

This amended patch is called by koha-common. koha-common runs this
process_message_queue.pl cronjob foreach enabled Koha instance on the server.

As this cronjob is run for every Koha instance the retrival of all
Koha instance names from debian/scripts/koha-scripts in previous
obsolete patches on this bug report and the looping through every name
to check if the lock file existed is redundant.

Instead this patch retrieves the 'logdir' of the Koha instance being
iterated over and checks if the messagequeue.lock file in that
directory is locked.

If the aforementioned file is not locked then the SendQueuedMessages()
in C4/Letters.pm is called, otherwise an email is sent (to the manually
inputted email server, and to/from addresses) and duplicate execution of the
cronjob is
prevented.

Test plan:
1. In two terminals open koha-shell and try to run
./process_message_queue.pl and notice you can run the script multiple
times simulataneously without a warning/error being displayed

2. Apply patch and input the email server, to/from email addresses you
would like the email to be sent to. Also confirm your Koha instance is
enabled to send emails.

3. Repeat step 1 and notice that the second of the two scripts to be
run will output text saying './process_message_queue.pl is already
running. Exiting'

In this case the aforementioned text is displayed and the body of the
cronjob is not run.

4. The first cronjob script to run, runs without issues

5. At the end of the execution of the first script a 15 second pause is
run

6. Notice you have received an email

Sponsored-By: New Zealand Parliamentary Library

Signed-off-by: Mark Tompsett <mtompset at hotmail.com>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list