pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15554: Broken pipe when doing a COPY of a parallel query
2+ messages / 2 participants
[nested] [flat]

* BUG #15554: Broken pipe when doing a COPY of a parallel query
@ 2018-12-17 08:57  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2018-12-17 08:57 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: luis.carril@swarm64.com

The following bug has been logged on the website:

Bug reference:      15554
Logged by:          Luis M Carril
Email address:      luis.carril@swarm64.com
PostgreSQL version: 10.6
Operating system:   Ubuntu 18.04
Description:        

Hi,
  when performing a COPY TO operation with the result of a parallel query a
'Broken Pipe' error is returned

Steps to reproduce:
    create table a(u int);
    insert into a select * from generate_series(1,1000000); -- enough data
to get a parallel plan
    copy ( select sum(u) from a) to program 'ls';  -- the SELECT has a
gather node
    ERROR:  could not close pipe to external command: Broken pipe
    
    Alternatively we can use the force_parallel_mode to reproduce it:
    set force_parallel_mode to on;
    copy ( select 1) to program 'ls'; -- this SELECT also has a gather
node
    ERROR:  could not close pipe to external command: Broken pipe

    Note that there is no broken pipe if there is no Gather node:
    set force_parallel_mode to on;
    copy ( select 1) to program 'ls';
    COPY 1


Pg Version:
                                            version                         
                  
  
-----------------------------------------------------------------------------------------------
   PostgreSQL 10.6 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
8.2.0-7ubuntu1) 8.2.0, 64-bit

Notes:
   The pclose call in FreeDesc (called by ClosePipeStream) is returning an
EINTR, which seems to trigger because during the wait several SIGUSR1 due to
the Gather node are triggered, which produces a SIGPIPE.

   I saw in the discussion of BUG #15449
(https://www.postgresql.org/message-id/flat/15449-1cf737dd5929450e%40postgresql.org)
a related comments to ClosePipeToProgram and SIGPIPE, I tried the last
submitted patch and the error still shows up.

   In the alpine Postgres docker image (postgres:10-alpine) the error does
not manifest (probably because uses musl as C library and pclose behaves
differently): 
                                          version                           
            
           
---------------------------------------------------------------------------------------
            PostgreSQL 10.6 on x86_64-pc-linux-musl, compiled by gcc (Alpine
6.4.0) 6.4.0, 64-bit

Cheers,
Luis M Carril



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

* Re: BUG #15554: Broken pipe when doing a COPY of a parallel query
@ 2018-12-17 14:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-12-17 14:50 UTC (permalink / raw)
  To: luis.carril@swarm64.com; +Cc: pgsql-bugs@lists.postgresql.org

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
>   when performing a COPY TO operation with the result of a parallel query a
> 'Broken Pipe' error is returned
> ...
>     set force_parallel_mode to on;
>     copy ( select 1) to program 'ls'; -- this SELECT also has a gather node
>     ERROR:  could not close pipe to external command: Broken pipe

I'm not convinced that this is a bug.  The external program did not
read the data we sent it, and it seems appropriate to report that.

>     Note that there is no broken pipe if there is no Gather node:
>     set force_parallel_mode to on;
>     copy ( select 1) to program 'ls';
>     COPY 1

(I think you meant "off" not "on" there.)  This is just a question of
timing: the parallel copy takes long enough to start up that the "ls"
has already done its thing and exited, so that we see EPIPE, while
the non-parallel case doesn't see the error.  Ideally we'd report an
error in both cases, but the kernel doesn't make it possible to do
that :-(.

With a larger chunk of COPY data, the error is reported a bit sooner,
with different text:

regression=# copy ( select u from a) to program 'ls';
ERROR:  could not write to COPY program: Broken pipe
regression=# copy ( select sum(u) from a) to program 'ls';
ERROR:  could not close pipe to external command: Broken pipe

Perhaps it's worth adding an fflush at the end, and reporting any
error from the fflush using "could not write to COPY program".
But that seems cosmetic.

			regards, tom lane




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


end of thread, other threads:[~2018-12-17 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 08:57 BUG #15554: Broken pipe when doing a COPY of a parallel query PG Bug reporting form <noreply@postgresql.org>
2018-12-17 14:50 ` 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