From 5c42f16bb0fde2ef46cc8b4bbd3d86c44d6fe7d4 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 8 Oct 2024 02:20:12 +0000 Subject: [PATCH] Bug 34027: (follow-up) Make sleep seconds a command-line param Use --logs-sleep SECONDS to specify how many seconds Koha should wait between batches when deleting action logs. Defaults to 3 Sponsored-by: Auckland University of Technology Sponsored-by: Catalyst IT --- misc/cronjobs/cleanup_database.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 7af1088b431..2aedddf8302 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -31,6 +31,7 @@ use constant DEFAULT_JOBS_PURGEDAYS => 1; use constant DEFAULT_JOBS_PURGETYPES => qw{ update_elastic_index }; use constant DEFAULT_EDIFACT_MSG_PURGEDAYS => 365; use constant DEFAULT_LOGS_BATCHSIZE => 1000; +use constant DEFAULT_LOGS_BATCHSLEEP => 3; use Getopt::Long qw( GetOptions ); @@ -90,6 +91,7 @@ Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Defaults to 180 days if no days specified. --logs-batch ROWS Delete action_logs rows in batches of ROWS. Ignored if --logs is not set. Defaults to 1000. + --logs-sleep SECS Sleeps for SECS seconds between each batch of action_logs rows deleted. Defaults to 3. --searchhistory DAYS purge entries from search_history older than DAYS days. Defaults to 30 days if no days specified --list-invites DAYS purge (unaccepted) list share invites older than DAYS days. @@ -175,6 +177,7 @@ my @jobs_types; my $reports; my $edifact_msg_days; my $logs_batch; +my $logs_sleep = 3; my $command_line_options = join( " ", @ARGV ); @@ -223,6 +226,7 @@ GetOptions( 'reports:i' => \$reports, 'edifact-messages:i' => \$edifact_msg_days, 'logs-batch:i' => \$logs_batch, + 'logs-sleep:i' => \$logs_sleep, ) || usage(1); # Use default values @@ -238,6 +242,7 @@ $jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) @jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; $edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; $logs_batch = DEFAULT_LOGS_BATCHSIZE if defined($logs_batch) && $logs_batch == 0; +$logs_sleep = DEFAULT_LOGS_BATCHSLEEP if defined($logs_sleep) && $logs_sleep == 0; # Choose the number of days at which to purge unaccepted list invites: # - DAYS defined in the list-invites parameter is prioritised first @@ -429,7 +434,7 @@ if ($pLogs) { do { $sth->execute(@query_params) or die $dbh->errstr; $rows_deleted = $sth->rows; - sleep 3; # Adjust sleep time as needed + sleep $logs_sleep; } while ( $rows_deleted == $logs_batch ); } else { $sth->execute(@query_params) or die $dbh->errstr; -- 2.39.5