Why does wait_for_log() return current file size

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Why does wait_for_log() return current file size
Date: 2025-03-29 15:15:47
Message-ID: s4hdlqga6473ffbmdopefmmklgxvb4n3s5yl5zkm2qyogk72gl@ar6bolnlsruo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

In a test I'd like to use wait_for_log() to find a bunch of log messages
emitted in sequence. A reasonable looking pattern for that would be:

$log_location = -s $node->logfile;

$log_location = $node->wait_for_log(qr/first-message/, $log_location);
$log_location = $node->wait_for_log(qr/second-message/, $log_location);

Except that that doesn't work, because what wait_for_log returns is:

my $log =
PostgreSQL::Test::Utils::slurp_file($self->logfile, $offset);

return $offset + length($log) if ($log =~ m/$regexp/);

Which, afaict, boils down to the current end of the logfile.

Could we instead determine where in the string our regex matched, and return
$offset + $that_magic_number

Assuming that could be made work, does anybody see a reason not to do that?

Greetings,

Andres Freund

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-03-29 15:54:24 Re: Amcheck verification of GiST and GIN
Previous Message Andres Freund 2025-03-29 14:48:10 Re: AIO v2.5