Address the bug in 041_checkpoint_at_promote.pl

From: Nitin Jadhav <nitinjadhavpostgres(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Address the bug in 041_checkpoint_at_promote.pl
Date: 2025-02-12 07:58:55
Message-ID: CAMm1aWa_6u+o52r7h7G6pX-oWD0Qraf0ee17Ma50qxGS0B_Rzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While testing, I discovered an issue in 041_checkpoint_at_promote.pl.

# Wait until the previous restart point completes on the newly-promoted
# standby, checking the logs for that.
my $checkpoint_complete = 0;
foreach my $i (0 .. 10 * $PostgreSQL::Test::Utils::timeout_default)
{
if ($node_standby->log_contains("restartpoint complete"), $logstart)
{
$checkpoint_complete = 1;
last;
}
usleep(100_000);
}
is($checkpoint_complete, 1, 'restart point has completed');

The code is intended to wait for the restart point to complete before
proceeding. However, it doesn't actually wait. Regardless of whether
the restart point completes, the loop exits after the first iteration
because the if condition always evaluates to true. This happens
because $logstart is not passed as an argument to log_contains() by
mistake. If the restart point operation is quick, this issue might not
be noticeable, which is often the case.

I've attached a patch to fix this issue. Please review and share your feedback.

Best Regards,
Nitin Jadhav
Azure Database for PostgreSQL
Microsoft

Attachment Content-Type Size
0001-Fix-the-bug-in-041_checkpoint_at_promote.pl.patch application/octet-stream 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-02-12 08:24:21 Re: Address the bug in 041_checkpoint_at_promote.pl
Previous Message Shubham Khanna 2025-02-12 07:48:27 Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided.