We start the automatic_renewal cron by getting all the checkouts that might be renewed We then loop through and try to renew each. In a large system this can take some time. If during that time an item in the list is checked in the cronjob will die when it tries to update the checkout. In my testing it only happens for items that will not be renewed. To recreate: 1 - Checkout an item to a patron and mark it for auto renewal 2 - Add 'sleep(10);' to the cronjob at line 194 3 - perl misc/cronjobs/automatic_renewals.pl -v -c 4 - Check the item in (quickly) 5 - The cron dies: DBIx::Class::Row::update(): Can't update Koha::Schema::Result::Issue=HASH(0x586e1a674fb0): row not found at /kohadevbox/koha/Koha/Object.pm line 172 DBIx::Class::Row::update(): Can't update Koha::Schema::Result::Issue=HASH(0x586e1a674fb0): row not found at /kohadevbox/koha/Koha/Object.pm line 172
Created attachment 169966 [details] [review] Bug 37552: Wrap auto renewal attempt in eval to ensure script does not die When libraries have a lot of checkouts, or an AMH, checkins can happen while the cron is running. This patch simply adds an eval around the auto renewal attempt in case of early check in or other errors. You can verify cron completed by enabling cronjob log in system preferences and checking the action logs To test: 1 - Add 'sleep(10);' to automatic_renewals.pl 2 - Set circulation rules to enable automatic renewals 3 - Issue an item to a patron 4 - perl misc/cronjobs/automatic_renewals.pl -v 5 - Confirm item would not be renewed 6 - perl misc/cronjobs/automatic_renewals.pl -v -c 7 - Quickly check in the item 8 - The cronjob dies DBIx::Class::Row::update(): Can't update Koha::Schema::Result::Issue=HASH(0x586e1a674fb0): row not found at /kohadevbox/koha/Koha/Object.pm line 172 9 - Apply patch 10 - Checkout the item again 11 - perl misc/cronjobs/automatic_renewals.pl -v -c 12 - Quickly checkin the item 13 - You get a warning, but the cron completes
Created attachment 170043 [details] [review] Bug 37552: Wrap auto renewal attempt in eval to ensure script does not die When libraries have a lot of checkouts, or an AMH, checkins can happen while the cron is running. This patch simply adds an eval around the auto renewal attempt in case of early check in or other errors. You can verify cron completed by enabling cronjob log in system preferences and checking the action logs To test: 1 - Add 'sleep(10);' to automatic_renewals.pl 2 - Set circulation rules to enable automatic renewals 3 - Issue an item to a patron 4 - perl misc/cronjobs/automatic_renewals.pl -v 5 - Confirm item would not be renewed 6 - perl misc/cronjobs/automatic_renewals.pl -v -c 7 - Quickly check in the item 8 - The cronjob dies DBIx::Class::Row::update(): Can't update Koha::Schema::Result::Issue=HASH(0x586e1a674fb0): row not found at /kohadevbox/koha/Koha/Object.pm line 172 9 - Apply patch 10 - Checkout the item again 11 - perl misc/cronjobs/automatic_renewals.pl -v -c 12 - Quickly checkin the item 13 - You get a warning, but the cron completes Signed-off-by: CJ Lynce <cj.lynce@westlakelibrary.org>
Confirmed that the existing script appears to die only with items that would not be renewed. The patch corrects this so that the script no longer dies, but produces an error and moves on, when an item is checked-in mid-processing of automatic renewals.
Created attachment 170320 [details] [review] Bug 37552: Wrap auto renewal attempt in eval to ensure script does not die When libraries have a lot of checkouts, or an AMH, checkins can happen while the cron is running. This patch simply adds an eval around the auto renewal attempt in case of early check in or other errors. You can verify cron completed by enabling cronjob log in system preferences and checking the action logs To test: 1 - Add 'sleep(10);' to automatic_renewals.pl 2 - Set circulation rules to enable automatic renewals 3 - Issue an item to a patron 4 - perl misc/cronjobs/automatic_renewals.pl -v 5 - Confirm item would not be renewed 6 - perl misc/cronjobs/automatic_renewals.pl -v -c 7 - Quickly check in the item 8 - The cronjob dies DBIx::Class::Row::update(): Can't update Koha::Schema::Result::Issue=HASH(0x586e1a674fb0): row not found at /kohadevbox/koha/Koha/Object.pm line 172 9 - Apply patch 10 - Checkout the item again 11 - perl misc/cronjobs/automatic_renewals.pl -v -c 12 - Quickly checkin the item 13 - You get a warning, but the cron completes Signed-off-by: CJ Lynce <cj.lynce@westlakelibrary.org> Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
I squashed in a perltidy, but otherwise the code looks good and the QA script is happy. Passing QA
There are some terminology "glitches" in the script (issue vs. checkout and borrower vs. patron), but I think that's for another day. Thanks for the patch!
Pushed for 24.11! Well done everyone, thank you!
Created attachment 171199 [details] [review] Bug 37552: (24.05.x) Wrap auto renewal attempt in eval to ensure script does not die
If someone wants to have a look at the 24.05.x specific patch I'd be happy to backport.
Nick OK'd the 24.05.x patch. Backported to 24.05.x for upcoming 24.05.04
Pushed to 23.11.x for 23.11.09
Not backporting to 23.05.x unless requested