Re: Cluster::restart dumping logs when stop fails

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cluster::restart dumping logs when stop fails
Date: 2024-04-06 22:19:35
Message-ID: 9AEB4FB5-5C70-4D1C-9A7B-AC37420DB3D9@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 6 Apr 2024, at 23:44, Andres Freund <andres(at)anarazel(dot)de> wrote:

> It might be useful to print a few lines, but the whole log files can be
> several megabytes worth of output.

The non-context aware fix would be to just print the last 1024 (or something)
bytes from the logfile:

diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 54e1008ae5..53d4751ffc 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -951,8 +951,8 @@ sub start

if ($ret != 0)
{
- print "# pg_ctl start failed; logfile:\n";
- print PostgreSQL::Test::Utils::slurp_file($self->logfile);
+ print "# pg_ctl start failed; logfile excerpt:\n";
+ print substr PostgreSQL::Test::Utils::slurp_file($self->logfile), -1024;

# pg_ctl could have timed out, so check to see if there's a pid file;
# otherwise our END block will fail to shut down the new postmaster.

Would that be a reasonable fix?

--
Daniel Gustafsson

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2024-04-06 22:22:51 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message Jelte Fennema-Nio 2024-04-06 22:14:03 Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs