From 3971736a50f3199d05442859331eaa52132c8813 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 27 Aug 2012 10:38:48 -0400 Subject: [PATCH] Repair fine generator memory leak Calling "next" from with a "try" block results in a memory leak, presumably because "try" is a sub wrapped in an eval (or vice versa, whatever, it leaks). Replacing the "try" with an "eval" avoids the leak. This particular leak in the fine generator is onerous when there are many circulations that are skipped (i.e. next'ed) in the main loop because they have no fine interval, rate, or max fine. This is seen in the osrfsys logs as: Fine Generator skipping circ 11995439 due to 0 fine interval, 0 fine rate, or 0 max fine. And accompanied in the stderr log by: Exiting eval via next at /usr/local/share/perl/5.10.1/OpenILS/Application/Storage/Publisher/action.pm line 820. Exiting subroutine via next at /usr/local/share/perl/5.10.1/OpenILS/Application/Storage/Publisher/action.pm line 820. Signed-off-by: Bill Erickson --- .../lib/OpenILS/Application/Storage/Publisher/action.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 4101309eae..c2ed9ef13e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -829,7 +829,7 @@ sub generate_fines { #TODO: reservation grace periods my $grace_period = ($is_reservation ? 0 : interval_to_seconds($c->grace_period)); - try { + eval { if ($self->method_lookup('open-ils.storage.transaction.current')->run) { $log->debug("Cleaning up after previous transaction\n"); $self->method_lookup('open-ils.storage.transaction.rollback')->run; @@ -1004,13 +1004,15 @@ sub generate_fines { )->gather(1); } - } catch Error with { - my $e = shift; + }; + + if ($@) { + my $e = $@; $client->respond( "Error processing overdue $ctype [".$c->id."]:\n\n$e\n" ); $log->error("Error processing overdue $ctype [".$c->id."]:\n$e\n"); $self->method_lookup('open-ils.storage.transaction.rollback')->run; - throw $e if ($e =~ /IS NOT CONNECTED TO THE NETWORK/o); - }; + last if ($e =~ /IS NOT CONNECTED TO THE NETWORK/o); + } } } __PACKAGE__->register_method( -- 2.11.0