Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMQuQ-0002Yk-UE for pgsql-committers@arkaria.postgresql.org; Wed, 06 Dec 2017 04:02:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMQuP-0003Dy-O4 for pgsql-committers@arkaria.postgresql.org; Wed, 06 Dec 2017 04:02:09 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eMQuP-0003Do-J4 for pgsql-committers@lists.postgresql.org; Wed, 06 Dec 2017 04:02:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eMQuI-0002rx-1P; Wed, 06 Dec 2017 04:02:09 +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 vB641x6w002091; Tue, 5 Dec 2017 23:01:59 -0500 From: Tom Lane To: Robert Haas cc: pgsql-committers@postgresql.org Subject: Re: pgsql: Support Parallel Append plan nodes. In-reply-to: <17868.1512519318@sss.pgh.pa.us> References: <17868.1512519318@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 05 Dec 2017 19:15:18 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <2005.1512532846.0@sss.pgh.pa.us> Date: Tue, 05 Dec 2017 23:01:59 -0500 Message-ID: <2090.1512532919@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2005.1512532846.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable I wrote: > Robert Haas writes: >> Support Parallel Append plan nodes. > Buildfarm member sidewinder doesn't like this: It transpires that my machine prairiedog also shows the failure. I instrumented nodeAppend.c (as per attached patch) to see what was going on, and I get this trace on prairiedog: 2017-12-05 22:50:30.228 EST [28812] LOG: choose_next_subplan_for_worker: = whichplan -1, nextplan -1, fpp 0, nplans 6 2017-12-05 22:50:30.228 EST [28812] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a1; 2017-12-05 22:50:30.241 EST [28813] LOG: choose_next_subplan_for_worker: = whichplan -1, nextplan -1, fpp 0, nplans 6 2017-12-05 22:50:30.241 EST [28813] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a1; 2017-12-05 22:50:30.252 EST [28814] LOG: choose_next_subplan_for_worker: = whichplan -1, nextplan -1, fpp 0, nplans 6 2017-12-05 22:50:30.252 EST [28814] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a1; 2017-12-05 22:50:30.363 EST [28816] LOG: choose_next_subplan_for_worker: = whichplan -1, nextplan 0, fpp 2, nplans 6 2017-12-05 22:50:30.363 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.363 EST [28816] LOG: choose_next_subplan_for_worker: = picking nextplan 0, fpp 2, nplans 6 2017-12-05 22:50:30.363 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.363 EST [28816] LOG: choose_next_subplan_for_worker: = whichplan 0, nextplan 1, fpp 2, nplans 6 2017-12-05 22:50:30.363 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.364 EST [28816] LOG: choose_next_subplan_for_worker: = picking nextplan 1, fpp 2, nplans 6 2017-12-05 22:50:30.364 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.364 EST [28816] LOG: choose_next_subplan_for_worker: = whichplan 1, nextplan 2, fpp 2, nplans 6 2017-12-05 22:50:30.364 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.364 EST [28816] LOG: choose_next_subplan_for_worker: = picking nextplan 2, fpp 2, nplans 6 2017-12-05 22:50:30.364 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.364 EST [28816] LOG: choose_next_subplan_for_worker: = whichplan 2, nextplan 3, fpp 2, nplans 6 2017-12-05 22:50:30.364 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.364 EST [28816] LOG: choose_next_subplan_for_worker: = picking nextplan 3, fpp 2, nplans 6 2017-12-05 22:50:30.364 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.365 EST [28816] LOG: choose_next_subplan_for_worker: = whichplan 3, nextplan 4, fpp 2, nplans 6 2017-12-05 22:50:30.365 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.365 EST [28816] LOG: choose_next_subplan_for_worker: = picking nextplan 4, fpp 2, nplans 6 2017-12-05 22:50:30.365 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.365 EST [28816] LOG: choose_next_subplan_for_worker: = whichplan 4, nextplan 5, fpp 2, nplans 6 2017-12-05 22:50:30.365 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.365 EST [28816] LOG: choose_next_subplan_for_worker: = picking nextplan 5, fpp 2, nplans 6 2017-12-05 22:50:30.365 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.365 EST [28816] LOG: choose_next_subplan_for_worker: = whichplan 5, nextplan 2, fpp 2, nplans 6 2017-12-05 22:50:30.365 EST [28816] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.407 EST [28815] LOG: choose_next_subplan_for_worker: = whichplan -1, nextplan -1, fpp 2, nplans 6 2017-12-05 22:50:30.407 EST [28815] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.474 EST [28817] LOG: choose_next_subplan_for_worker: = whichplan -1, nextplan -1, fpp 2, nplans 6 2017-12-05 22:50:30.474 EST [28817] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a2; 2017-12-05 22:50:30.568 EST [28818] LOG: choose_next_subplan_for_worker: = whichplan -1, nextplan 0, fpp 6, nplans 6 2017-12-05 22:50:30.568 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.568 EST [28818] LOG: choose_next_subplan_for_worker: = picking nextplan 0, fpp 6, nplans 6 2017-12-05 22:50:30.568 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.569 EST [28818] LOG: choose_next_subplan_for_worker: = whichplan 0, nextplan 1, fpp 6, nplans 6 2017-12-05 22:50:30.569 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.569 EST [28818] LOG: choose_next_subplan_for_worker: = picking nextplan 1, fpp 6, nplans 6 2017-12-05 22:50:30.569 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.569 EST [28818] LOG: choose_next_subplan_for_worker: = whichplan 1, nextplan 2, fpp 6, nplans 6 2017-12-05 22:50:30.569 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.569 EST [28818] LOG: choose_next_subplan_for_worker: = picking nextplan 2, fpp 6, nplans 6 2017-12-05 22:50:30.569 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.570 EST [28818] LOG: choose_next_subplan_for_worker: = whichplan 2, nextplan 3, fpp 6, nplans 6 2017-12-05 22:50:30.570 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.570 EST [28818] LOG: choose_next_subplan_for_worker: = picking nextplan 3, fpp 6, nplans 6 2017-12-05 22:50:30.570 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.570 EST [28818] LOG: choose_next_subplan_for_worker: = whichplan 3, nextplan 4, fpp 6, nplans 6 2017-12-05 22:50:30.570 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.570 EST [28818] LOG: choose_next_subplan_for_worker: = picking nextplan 4, fpp 6, nplans 6 2017-12-05 22:50:30.570 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.570 EST [28818] LOG: choose_next_subplan_for_worker: = whichplan 4, nextplan 5, fpp 6, nplans 6 2017-12-05 22:50:30.570 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; 2017-12-05 22:50:30.570 EST [28818] LOG: choose_next_subplan_for_worker: = picking nextplan 5, fpp 6, nplans 6 2017-12-05 22:50:30.570 EST [28818] STATEMENT: select round(avg(aa)), sum= (aa) from a_star a3; TRAP: FailedAssertion("!(append->first_partial_plan < node->as_nplans)", F= ile: "nodeAppend.c", Line: 520) 2017-12-05 22:50:38.211 EST [28158] LOG: background worker "parallel work= er" (PID 28818) was terminated by signal 6: Abort trap 2017-12-05 22:50:38.211 EST [28158] DETAIL: Failed process was running: s= elect round(avg(aa)), sum(aa) from a_star a3; That makes it pretty clear what's going wrong, but why don't we see it elsewhere? On my development machine, the same patch yields 2017-12-05 22:42:24.187 EST [843] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 0, nplans 6 2017-12-05 22:42:24.187 EST [843] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a1; 2017-12-05 22:42:24.188 EST [844] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 0, nplans 6 2017-12-05 22:42:24.188 EST [844] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a1; 2017-12-05 22:42:24.188 EST [845] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 0, nplans 6 2017-12-05 22:42:24.188 EST [845] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a1; 2017-12-05 22:42:24.197 EST [846] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 2, nplans 6 2017-12-05 22:42:24.197 EST [846] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a2; 2017-12-05 22:42:24.200 EST [847] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 2, nplans 6 2017-12-05 22:42:24.200 EST [847] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a2; 2017-12-05 22:42:24.200 EST [848] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 2, nplans 6 2017-12-05 22:42:24.200 EST [848] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a2; 2017-12-05 22:42:24.214 EST [849] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 6, nplans 6 2017-12-05 22:42:24.214 EST [849] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a3; 2017-12-05 22:42:24.214 EST [852] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 6, nplans 6 2017-12-05 22:42:24.214 EST [852] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a3; 2017-12-05 22:42:24.214 EST [853] LOG: choose_next_subplan_for_worker: wh= ichplan -1, nextplan -1, fpp 6, nplans 6 2017-12-05 22:42:24.214 EST [853] STATEMENT: select round(avg(aa)), sum(a= a) from a_star a3; I conclude that the reason we don't see the crash except on the slowest buildfarm critters is that on most machines the leader process manages to finish off all the subplans before any of the workers get as far as doing something. This doesn't give me a warm fuzzy feeling about how much testing this patch has gotten. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="instrument-choose_next_subplan_for_worker.patch"; charset="us-ascii" Content-ID: <2005.1512532846.2@sss.pgh.pa.us> Content-Description: instrument-choose_next_subplan_for_worker.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/node= Append.c index 246a0b2..4c4355b 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -463,6 +463,12 @@ choose_next_subplan_for_worker(AppendState *node) = LWLockAcquire(&pstate->pa_lock, LW_EXCLUSIVE); = + elog(LOG, "choose_next_subplan_for_worker: whichplan %d, nextplan %d, fp= p %d, nplans %d", + node->as_whichplan, + pstate->pa_next_plan, + append->first_partial_plan, + node->as_nplans); + /* Mark just-completed subplan as finished. */ if (node->as_whichplan !=3D INVALID_SUBPLAN_INDEX) node->as_pstate->pa_finished[node->as_whichplan] =3D true; @@ -502,6 +508,11 @@ choose_next_subplan_for_worker(AppendState *node) } } = + elog(LOG, "choose_next_subplan_for_worker: picking nextplan %d, fpp %d, = nplans %d", + pstate->pa_next_plan, + append->first_partial_plan, + node->as_nplans); + /* Pick the plan we found, and advance pa_next_plan one more time. */ node->as_whichplan =3D pstate->pa_next_plan++; if (pstate->pa_next_plan >=3D node->as_nplans) ------- =_aaaaaaaaaa0--