Re: Cluster::restart dumping logs when stop fails

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Andres Freund <andres(at)anarazel(dot)de>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cluster::restart dumping logs when stop fails
Date: 2024-04-07 12:51:06
Message-ID: 332deaa1-5a92-4105-aa25-7ed2c00839ad@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey M. Borodin 2024-04-07 12:52:16 Re: MultiXact\SLRU buffers configuration
Previous Message Ranier Vilela 2024-04-07 12:42:54 Re: Flushing large data immediately in pqcomm