Bugzilla – Attachment 142509 Details for
Bug 31629
Cleanup database needs a flag for removing elastic index entries from background_jobs table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31629: Add jobsqueue options to cleanup_database
Bug-31629-Add-jobsqueue-options-to-cleanupdatabase.patch (text/plain), 4.34 KB, created by
Nick Clemens (kidclamp)
on 2022-10-24 13:55:13 UTC
(
hide
)
Description:
Bug 31629: Add jobsqueue options to cleanup_database
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-10-24 13:55:13 UTC
Size:
4.34 KB
patch
obsolete
>From 9054d01a3e58d45f5ff379e113a7d92fc774f7db Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= <f.demians@tamil.fr> >Date: Mon, 24 Oct 2022 15:16:23 +0200 >Subject: [PATCH] Bug 31629: Add jobsqueue options to cleanup_database > >This patch adds an jobsqueue option to cleanup_database.pl to allow >for purging background jobs queue > >There is also a fix for --elasticqueue default value > >To test: > >1. On a DB with a populated background_jobs table, identify in this > table > entries older than X days. >2. perl misc/cronjobs/cleanup_database.pl > Note elasticqueue entry shows in help >3. perl misc/cronjobs/cleanup_database.pl --elasticqueue -v > Note this message: > Elastic queue (background jobs) purge triggered for 30 days >4. perl misc/cronjobs/cleanup_database.pl --jobsqueue -v > Note this message: > Background jobs queue purge triggered for 30 days. >5. perl misc/cronjobs/cleanup_database.pl --jobsqueue 1 -v > Background jobs queue purge triggered for 1 day. >6. perl misc/cronjobs/cleanup_database.pl --jobsqueue 1 -v --confirm > Note that number of entries deleted is reporte >7. In Koha > Admin > Background jobs, see the purge queue. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > misc/cronjobs/cleanup_database.pl | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index b0990f156a..8488c6a105 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -21,6 +21,7 @@ use Modern::Perl; > > use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; > use constant DEFAULT_ELASTICQ_PURGEDAYS => 30; >+use constant DEFAULT_JOBS_PURGEDAYS => 30; > use constant DEFAULT_MAIL_PURGEDAYS => 30; > use constant DEFAULT_IMPORT_PURGEDAYS => 60; > use constant DEFAULT_LOGS_PURGEDAYS => 180; >@@ -121,6 +122,7 @@ my $sess_days; > my $verbose; > my $zebraqueue_days; > my $elasticqueue_days; >+my $jobsqueue_days; > my $mail; > my $purge_merged; > my $pImport; >@@ -164,6 +166,7 @@ GetOptions( > 'm|mail:i' => \$mail, > 'zebraqueue:i' => \$zebraqueue_days, > 'elasticqueue:i' => \$elasticqueue_days, >+ 'jobsqueue:i' => \$jobsqueue_days, > 'merged' => \$purge_merged, > 'import:i' => \$pImport, > 'z3950' => \$pZ3950, >@@ -202,6 +205,8 @@ $sessions = 1 if $sess_days > $pImport = DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport == 0; > $pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs == 0; > $zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; >+$elasticqueue_days = DEFAULT_ELASTICQ_PURGEDAYS if defined($elasticqueue_days) && $elasticqueue_days == 0; >+$jobsqueue_days = DEFAULT_JOBS_PURGEDAYS if defined($jobsqueue_days) && $jobsqueue_days == 0; > $mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; > $pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; > $pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; >@@ -215,6 +220,7 @@ if ($help) { > unless ( $sessions > || $zebraqueue_days > || $elasticqueue_days >+ || $jobsqueue_days > || $mail > || $purge_merged > || $pImport >@@ -329,6 +335,25 @@ if ($elasticqueue_days) { > } > } > >+if ($jobsqueue_days) { >+ my $count = 0; >+ print "Background jobs queue purge triggered for $jobsqueue_days days.\n" if $verbose; >+ $sth = $dbh->prepare( >+ q{ >+ DELETE FROM background_jobs >+ WHERE status='finished' AND ended_on < date_sub(curdate(), INTERVAL ? DAY) >+ } >+ ); >+ if ( $confirm ) { >+ $sth->execute($jobsqueue_days) or die $dbh->errstr; >+ $count = $sth->rows; >+ } >+ if ( $verbose ) { >+ say $confirm ? "$count jobs were deleted from the background jobs queue." : "All entries from backgorund jobs queue would have been deleted"; >+ say "Done with background jobs queue purge."; >+ } >+} >+ > if ($mail) { > my $count = 0; > print "Mail queue purge triggered for $mail days.\n" if $verbose; >-- >2.30.2
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 31629
:
141837
|
141850
|
142492
|
142501
|
142502
|
142508
| 142509 |
142510