Re: IPC::Run accepts bug reports - Mailing list pgsql-hackers

From Noah Misch
Subject Re: IPC::Run accepts bug reports
Date
Msg-id 20241004185748.22.nmisch@google.com
Whole thread Raw
In response to Re: IPC::Run accepts bug reports  (Alexander Lakhin <exclusion@gmail.com>)
Responses Re: IPC::Run accepts bug reports
List pgsql-hackers
On Fri, Oct 04, 2024 at 02:00:00PM +0300, Alexander Lakhin wrote:
> sub _read {
> ...
>     my $r = POSIX::read( $_[0], $s, 10_000 );
>     croak "$!: read( $_[0] )" if not($r) and !$!{EINTR};
> 
> That is, EINTR kind of recognized as an expected error, but there is no
> retry in this case. Thus, with the following modification, which simulates
> read() failed with EINTR:
>  sub _read {
>      confess 'undef' unless defined $_[0];
>      my $s = '';
> -    my $r = POSIX::read( $_[0], $s, 10_000 );
> +    my $r;
> +if (int(rand(100)) == 0)
> +{
> +   $r = 0;  $! = Errno::EINTR;
> +}
> +else
> +{
> +    $r = POSIX::read( $_[0], $s, 10_000 );
> +}
>      croak "$!: read( $_[0] )" if not($r) and !$!{EINTR};
> 
> I can see failures like the one in question when running that test.

That makes sense.  Would you file this at
https://github.com/cpan-authors/IPC-Run/issues?  I suppose that code should
become roughly:

  do { $r = POSIX::read(...) } while (!defined($r) && $!{EINTR});
  croak ... unless defined($r);

> Perhaps, I could reproduce the issue with a program, that sends signals
> to running (pgbench) processes (and thus interrupts read()), if it makes
> sense.

That should work.  Best would be an IPC::Run test case, like the existing
t/eintr.t that makes select() report EINTR.  That said, IPC::Run could adopt
the retry without a test.

> [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=indri&dt=2024-10-02%2002%3A34%3A16



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: POC, WIP: OR-clause support for indexes
Next
From: Tom Lane
Date:
Subject: Re: ECPG cleanup and fix for clang compile-time problem