Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMVJm-0000zb-LT for pgsql-committers@arkaria.postgresql.org; Wed, 06 Dec 2017 08:44:38 +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 1eMVJl-000206-Lj for pgsql-committers@arkaria.postgresql.org; Wed, 06 Dec 2017 08:44:37 +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 1eMVJl-0001zq-ER for pgsql-committers@lists.postgresql.org; Wed, 06 Dec 2017 08:44:37 +0000 Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eMVJh-0000NL-1O for pgsql-committers@postgresql.org; Wed, 06 Dec 2017 08:44:36 +0000 Received: by mail-io0-x22b.google.com with SMTP id u42so1819533ioi.9 for ; Wed, 06 Dec 2017 00:44:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ellkRxykWMEWXW9TNk46gHeR71au16Gmv/nB4e76his=; b=UUa05+Zip8yAgEfDXDZtbBMUM/vglXygJ7g82OO+h34BfqNBfti8Ux1z+TFO4dImU2 pZAaxNmCsSb/jf42xXHEsb9sI6EZB/xCSIzn+t9bBxD/4sPHm23hwd6r9cksxxkGBLGa d716tTTMwRidae/+oh3XJt54YOgkn1H/Ly3Nx/Pptp2vZrvxKzSeOJxieV+1ik8zbQda Q05e5Q39s8O3yQG367CBsRbjbvyqfMXt2dUa/sBKHIPlNhqNi4iGunmktfFrdhKd8UAc QVtGhx0+M9+tfxcxUqvzK2DOt4+EiLjRaazGYQPBeePvQt22ksX/sy/JN7iTf2U4Csdi 1E7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ellkRxykWMEWXW9TNk46gHeR71au16Gmv/nB4e76his=; b=HOuNvvPpDDVFkkoqpo56zPlXy3gfkTrJcezZtcpooKEP1v2SEW3hI0WpJojgBgctr5 x4QJpyt9D3U2Q8uB8Cp1869/FdKh9KzJDgl7d7zDFCc3UE4prB+sUmdoCgh2WAIwuzAh pjjAbAj9CoYrS+T+Mkdqkfx5i4G+13TH/oQtdKaPPZyeYEM39BXXwfWtlJtudEbqSlWd aCB3Q4VXktKQjVvQmP504WtU9Tvh+8/eAncRLkjBoZmjVC0RI+B31aQRT6aJDipvlhao 85Blyjn0KqQZpD3qAnNxzJx6Jf6z27bT59nhpCcThOm4iIUtLbVX+TY0/mLYQvnvlrKj 1xPg== X-Gm-Message-State: AKGB3mIg6tISvj7fVoucOdxZbYyajz1fH5AV51vI29cZ62Jq7V/EJ3YH RogoYGiNF1MEzF2C1v1+mT4JnsOKxZWe4WImoZoGxQ== X-Google-Smtp-Source: AGs4zMa1/uiI0Ls2yRqGIC2AAFeQag1NuDwNGhyaJLnF8q5Ov9cW+d5UaPpJJwH+Nqz095wh2EHmtxjPreeExQUCnZU= X-Received: by 10.107.195.140 with SMTP id t134mr9404779iof.216.1512549870242; Wed, 06 Dec 2017 00:44:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.198.68 with HTTP; Wed, 6 Dec 2017 00:43:49 -0800 (PST) From: Amit Khandekar Date: Wed, 6 Dec 2017 14:13:49 +0530 Message-ID: Subject: Re: pgsql: Support Parallel Append plan nodes. To: pgsql-committers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6 November 2017 16:50, amul sul wrote: > Thanks Tom for the crash analysis, I think this is the same reason that > Rajkumar's reported case[1] was crashing only with partition-wise-join = on. > I tried to fix this crash[2] but missed the place where I have added assert > check in the assumption that we always coming from the previous check in the > while loop. > > Instead, assert check we need a similar bailout logic[2] before looping back to > first partial plan. Attached patch does the same, I've tested with > parallel_leader_participation = off setting as suggested by Andres, make check > looks good except there is some obvious regression diff. > > 1] https://postgr.es/m/CAKcux6m+6nTO6C08kKaj-Waffvgvp-9SD3RCGStX=Mzk0gQU8g@mail.gmail.com > 2] https://postgr.es/m/CAAJ_b975k58H+Ed4=p0vbJunwO2reOMX5CVB8_R=JmXxY3uW=Q@mail.gmail.com > @@ -506,7 +506,14 @@ choose_next_subplan_for_worker(AppendState *node) node->as_whichplan = pstate->pa_next_plan++; if (pstate->pa_next_plan >= node->as_nplans) { - Assert(append->first_partial_plan < node->as_nplans); + /* No partial plans then bail out. */ + if (append->first_partial_plan >= node->as_nplans) + { + pstate->pa_next_plan = INVALID_SUBPLAN_INDEX; + node->as_whichplan = INVALID_SUBPLAN_INDEX; + LWLockRelease(&pstate->pa_lock); + return false; + } pstate->pa_next_plan = append->first_partial_plan; In the above code, the fact that we have not bailed out from the earlier for loop means that we have already found an unfinished plan and node->as_whichplan is set to that plan. So while setting the next plan above for the other workers to pick, we should not return false, nor should we set node->as_whichplan to INVALID_SUBPLAN_INDEX. Instead, just set pa_next_plan to INVALID_SUBPLAN_INDEX. Otherwise, the chosen plan won't get executed at all. Thanks -Amit Khandekar