Re: Cluster::restart dumping logs when stop fails - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Cluster::restart dumping logs when stop fails
Date
Msg-id 332deaa1-5a92-4105-aa25-7ed2c00839ad@dunslane.net
Whole thread Raw
In response to Re: Cluster::restart dumping logs when stop fails  (Andres Freund <andres@anarazel.de>)
Responses Re: Cluster::restart dumping logs when stop fails
List pgsql-hackers


On 2024-04-06 Sa 20:49, Andres Freund wrote:

That's probably unnecessary optimization, but it seems a tad silly to read an
entire, potentially sizable, file to just use the last 1k. Not sure if the way
slurp_file() uses seek supports negative ofsets, the docs read to me like that
may only be supported with SEEK_END.


We should enhance slurp_file() so it uses SEEK_END if the offset is negative. It would be a trivial patch:


diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
index 42d5a50dc8..8256573957 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -524,7 +524,7 @@ sub slurp_file
 
    if (defined($offset))
    {
-       seek($fh, $offset, SEEK_SET)
+       seek($fh, $offset, ($offset < 0 ? SEEK_END : SEEK_SET))
          or croak "could not seek \"$filename\": $!";
    }

cheers


andrew


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: Flushing large data immediately in pqcomm
Next
From: "Andrey M. Borodin"
Date:
Subject: Re: MultiXact\SLRU buffers configuration