Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYuDv-0006A0-Ob for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Dec 2018 14:50:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYuDu-0003oz-CA for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Dec 2018 14:50:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYuDu-0003os-6E for pgsql-bugs@lists.postgresql.org; Mon, 17 Dec 2018 14:50:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYuDr-0007gC-QG for pgsql-bugs@lists.postgresql.org; Mon, 17 Dec 2018 14:50:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wBHEoGTw028347; Mon, 17 Dec 2018 09:50:16 -0500 From: Tom Lane To: luis.carril@swarm64.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15554: Broken pipe when doing a COPY of a parallel query In-reply-to: <15554-04979fa61a082393@postgresql.org> References: <15554-04979fa61a082393@postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Mon, 17 Dec 2018 08:57:16 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28345.1545058216.1@sss.pgh.pa.us> Date: Mon, 17 Dec 2018 09:50:16 -0500 Message-ID: <28346.1545058216@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= 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