pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
trivial improvement to system_or_bail
5+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2021-07-06 5798ca5299  Improve TestLib::system_or_bail error reporting
* trivial improvement to system_or_bail
@ 2021-06-30 15:24 Alvaro Herrera <alvherre@alvh.no-ip.org>
  2021-06-30 15:36 ` Re: trivial improvement to system_or_bail Daniel Gustafsson <daniel@yesql.se>
  2021-06-30 15:45 ` Re: trivial improvement to system_or_bail Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 5+ messages in thread

From: Alvaro Herrera @ 2021-06-30 15:24 UTC (permalink / raw)
  To: Pg Hackers <pgsql-hackers@lists.postgresql.org>

When PostgresNode::system_or_bail() fails, it's quite opaque as to what
is happening.  This patch improves things by printing some detail, as
suggested in Perl's doc for system().

-- 
Álvaro Herrera                            39°49'30"S 73°17'W
                               https://www.EnterpriseDB.com/

Attachments:

system_or_bail.patch (text/x-diff, 704B) download AuthorDate: Tue Jun 15 12:46:42 2021 -0400 CommitDate: Tue Jun 15 12:46:54 2021 -0400 improve TestLib::system_or_bail reporting of system() failures diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 26fbe08d4b..eb49923b42 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -375,7 +375,18 @@ sub system_or_bail { if (system_log(@_) != 0) { - BAIL_OUT("system $_[0] failed"); + if ($? == -1) + { + BAIL_OUT("system $_[0] failed: $!\n"); + } + elsif ($? & 127) + { + BAIL_OUT(sprintf("system $_[0] died with signal %d\n", $? & 127)); + } + else + { + BAIL_OUT(sprintf("system $_[0] exited with value %d\n", $? >> 8)); + } } return; }
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: trivial improvement to system_or_bail
  2021-06-30 15:24 trivial improvement to system_or_bail Alvaro Herrera <alvherre@alvh.no-ip.org>
@ 2021-06-30 15:36 ` Daniel Gustafsson <daniel@yesql.se>
  2021-07-06 21:59   ` Re: trivial improvement to system_or_bail Alvaro Herrera <alvherre@alvh.no-ip.org>
  1 sibling, 1 reply; 5+ messages in thread

From: Daniel Gustafsson @ 2021-06-30 15:36 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>

> On 30 Jun 2021, at 17:24, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> 
> When PostgresNode::system_or_bail() fails, it's quite opaque as to what
> is happening.  This patch improves things by printing some detail, as
> suggested in Perl's doc for system().

+1 on this from reading the patch.

+			BAIL_OUT("system $_[0] failed: $!\n");
I wonder if we should take more inspiration from the Perl manual and change it
to "failed to execute" to make it clear that the failure was in executing the
program, not from the program itself?

--
Daniel Gustafsson		https://vmware.com/






^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: trivial improvement to system_or_bail
  2021-06-30 15:24 trivial improvement to system_or_bail Alvaro Herrera <alvherre@alvh.no-ip.org>
  2021-06-30 15:36 ` Re: trivial improvement to system_or_bail Daniel Gustafsson <daniel@yesql.se>
@ 2021-07-06 21:59   ` Alvaro Herrera <alvherre@alvh.no-ip.org>
  2021-07-07 07:13     ` Re: trivial improvement to system_or_bail Daniel Gustafsson <daniel@yesql.se>
  0 siblings, 1 reply; 5+ messages in thread

From: Alvaro Herrera @ 2021-07-06 21:59 UTC (permalink / raw)
  To: Daniel Gustafsson <daniel@yesql.se>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>

On 2021-Jun-30, Daniel Gustafsson wrote:

> +			BAIL_OUT("system $_[0] failed: $!\n");
> I wonder if we should take more inspiration from the Perl manual and change it
> to "failed to execute" to make it clear that the failure was in executing the
> program, not from the program itself?

You're right, that's a good distinction to make.  I've used this
wording.  Thanks.

> +1 for adding the extra details, but another thing that I've always found
> very confusing is just the phrasing of the message itself.  It makes
> no sense unless (a) you know that "system" is Perl's function for
> executing a shell command, (b) you are familiar with Perl's generally
> cavalier approach to parentheses, and (c) you are also unbothered by
> whether the word "failed" is part of the message text or the command
> being complained of.  We really need to do something to set off the
> shell command's text from the surrounding verbiage a little better.
> 
> I'd prefer something like
> 
> 	command "pg_ctl start" failed: details here

Done that way, thanks for the suggestion.

Failures now look like this, respectively:

Bailout called.  Further testing stopped:  failed to execute command "finitdb -D /home/alvherre/Code/pgsql-build/master/src/test/recovery/tmp_check/t_019_replslot_limit_primary_data/pgdata -A trust -N --wal-segsize=1": No such file or directory

Bailout called.  Further testing stopped:  command "initdb -0D /home/alvherre/Code/pgsql-build/master/src/test/recovery/tmp_check/t_019_replslot_limit_primary_data/pgdata -A trust -N --wal-segsize=1" exited with value 1

Bailout called.  Further testing stopped:  command "initdb -0D /home/alvherre/Code/pgsql-build/master/src/test/recovery/tmp_check/t_019_replslot_limit_primary_data/pgdata -A trust -N --wal-segsize=1" died with signal 11


Previously it was just

Bailout called.  Further testing stopped:  system initdb failed

-- 
Álvaro Herrera              Valdivia, Chile  —  https://www.EnterpriseDB.com/
"I must say, I am absolutely impressed with what pgsql's implementation of
VALUES allows me to do. It's kind of ridiculous how much "work" goes away in
my code.  Too bad I can't do this at work (Oracle 8/9)."       (Tom Allison)
           http://archives.postgresql.org/pgsql-general/2007-06/msg00016.php





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: trivial improvement to system_or_bail
  2021-06-30 15:24 trivial improvement to system_or_bail Alvaro Herrera <alvherre@alvh.no-ip.org>
  2021-06-30 15:36 ` Re: trivial improvement to system_or_bail Daniel Gustafsson <daniel@yesql.se>
  2021-07-06 21:59   ` Re: trivial improvement to system_or_bail Alvaro Herrera <alvherre@alvh.no-ip.org>
@ 2021-07-07 07:13     ` Daniel Gustafsson <daniel@yesql.se>
  0 siblings, 0 replies; 5+ messages in thread

From: Daniel Gustafsson @ 2021-07-07 07:13 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Pg Hackers <pgsql-hackers@lists.postgresql.org>

> On 6 Jul 2021, at 23:59, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

> Failures now look like this, respectively:
> 
> Bailout called.  Further testing stopped:  failed to execute command "finitdb -D /home/alvherre/Code/pgsql-build/master/src/test/recovery/tmp_check/t_019_replslot_limit_primary_data/pgdata -A trust -N --wal-segsize=1": No such file or directory
> 
> Bailout called.  Further testing stopped:  command "initdb -0D /home/alvherre/Code/pgsql-build/master/src/test/recovery/tmp_check/t_019_replslot_limit_primary_data/pgdata -A trust -N --wal-segsize=1" exited with value 1
> 
> Bailout called.  Further testing stopped:  command "initdb -0D /home/alvherre/Code/pgsql-build/master/src/test/recovery/tmp_check/t_019_replslot_limit_primary_data/pgdata -A trust -N --wal-segsize=1" died with signal 11
> 
> 
> Previously it was just
> 
> Bailout called.  Further testing stopped:  system initdb failed

That is no doubt going to be helpful, thanks!

--
Daniel Gustafsson		https://vmware.com/






^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: trivial improvement to system_or_bail
  2021-06-30 15:24 trivial improvement to system_or_bail Alvaro Herrera <alvherre@alvh.no-ip.org>
@ 2021-06-30 15:45 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-06-30 15:45 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> When PostgresNode::system_or_bail() fails, it's quite opaque as to what
> is happening.  This patch improves things by printing some detail, as
> suggested in Perl's doc for system().

+1 for adding the extra details, but another thing that I've always found
very confusing is just the phrasing of the message itself.  It makes
no sense unless (a) you know that "system" is Perl's function for
executing a shell command, (b) you are familiar with Perl's generally
cavalier approach to parentheses, and (c) you are also unbothered by
whether the word "failed" is part of the message text or the command
being complained of.  We really need to do something to set off the
shell command's text from the surrounding verbiage a little better.

I'd prefer something like

	command "pg_ctl start" failed: details here

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2021-07-07 07:13 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 15:24 trivial improvement to system_or_bail Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-06-30 15:36 ` Daniel Gustafsson <daniel@yesql.se>
2021-07-06 21:59   ` Alvaro Herrera <alvherre@alvh.no-ip.org>
2021-07-07 07:13     ` Daniel Gustafsson <daniel@yesql.se>
2021-06-30 15:45 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox