From d57a7685fa483828c062c191e9b62ab488a37032 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Mon, 18 Sep 2023 12:17:29 +0200 Subject: [PATCH] MT#58299 do not stop archiving upon a missing table Change-Id: I6d50e3234df471eaedf05a4a02cf6416beb688b8 --- lib/NGCP/Cleanup.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/NGCP/Cleanup.pm b/lib/NGCP/Cleanup.pm index 3ec0ab3..c2a3c79 100644 --- a/lib/NGCP/Cleanup.pm +++ b/lib/NGCP/Cleanup.pm @@ -587,13 +587,16 @@ sub archive_dump { my $pass = $self->env('pass') // $self->env('password'); my $host = $self->env('host'); - while (1) { - my $now = DateTime->now(time_zone => 'local'); - my $bm = $now->clone; + my $now = DateTime->now(time_zone => 'local'); + my $bm = $now->clone; + while ($bm->strftime('%Y%m') ge '198001') { + $now = DateTime->now(time_zone => 'local'); + $bm = $now->clone; $bm->subtract(months => $month)->truncate(to => "month"); my $mtable = $table . "_" . $bm->strftime('%Y%m'); my $res = $dbh->selectcol_arrayref("show table status like ?", undef, $mtable); - ($res && @$res && $res->[0]) or last; + $month++; + ($res && @$res && $res->[0]) or next; if ($target ne '/dev/null') { my $fname = sprintf("%s/%s.%s.sql", $target, $mtable, $now->strftime("%Y%m%d%H%M%S")); @@ -621,7 +624,6 @@ sub archive_dump { } $self->debug("drop table=$mtable"); $dbh->do("drop table $mtable"); - $month++; } }