Re: BackgroundPsql swallowing errors on windows

From: Andres Freund <andres(at)anarazel(dot)de>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: BackgroundPsql swallowing errors on windows
Date: 2025-02-16 18:02:01
Message-ID: h6t2voqv6vm4xk4oh5q6og676h7ehv2opbvr2id7m2xot3adh5@t7su2dmuo3bs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2025-02-16 09:39:43 -0800, Noah Misch wrote:
> On Thu, Feb 13, 2025 at 12:39:04PM -0500, Andres Freund wrote:
> > I suspect what's happening is that the communication with the
> > external process allows for reordering between stdout/stderr.
> >
> > And indeed, changing BackgroundPsql::query() to emit the banner on both stdout
> > and stderr and waiting on both seems to fix the issue.
>
> That makes sense. I wondered how one might fix IPC::Run to preserve the
> relative timing of stdout and stderr, not perturbing the timing the way that
> disrupted your test run. I can think of two strategies:
>
> - Remove the proxy.
>
> - Make pipe data visible to Perl variables only when at least one of the
> proxy<-program_under_test pipes had no data ready to read. In other words,
> if both pipes have data ready, make all that data visible to Perl code
> simultaneously. (When both the stdout pipe and the stderr pipe have data
> ready, one can't determine data arrival order.)
>
> Is there a possibly-less-invasive change that might work?

I don't really know enough about IPC::Run's internals to answer. My
interpretation of how it might work, purely from observation, is that it opens
one tcp connection for each "pipe" and that that's what's introducing the
potential of reordering, as the different sockets can have different delivery
timeframes. If that's it, it seems proxying all the pipes through one
connection might be an option.

I did briefly look at IPC::Run's code, but couldn't figure out how it all fits
together quickly enough...

> v2 of the patch looks fine.

Thanks for reviewing!

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-02-16 18:12:18 Re: Confine vacuum skip logic to lazy_scan_skip
Previous Message Noah Misch 2025-02-16 17:39:43 Re: BackgroundPsql swallowing errors on windows