Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMSzz-0001Ac-2T for pgsql-committers@arkaria.postgresql.org; Wed, 06 Dec 2017 06:16:03 +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 1eMSzy-0001uu-J2 for pgsql-committers@arkaria.postgresql.org; Wed, 06 Dec 2017 06:16:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eMSzy-0001uY-4N for pgsql-committers@lists.postgresql.org; Wed, 06 Dec 2017 06:16:02 +0000 Received: from mail-qt0-x229.google.com ([2607:f8b0:400d:c0d::229]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eMSzv-00065q-5u; Wed, 06 Dec 2017 06:16:00 +0000 Received: by mail-qt0-x229.google.com with SMTP id e2so6547684qti.0; Tue, 05 Dec 2017 22:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=JPO9ByPKmLGHIlVh9HNa1aojPSx0RjzMLohjZr9MFt0=; b=XEhhEmmAc+bX1hUoE9mI47YeO8JkllEUE/Ry/K23t69fsGq7Cr/aj3bLamj/nmwefq 26a2sKfPF3kK8E0+z4cLs2xsgxa45hJa2lB/xW8iXM6ylsMsy/y8vGncAu0ANOcAlksX lYaVO2gMQMpCVd2ksg5ctcyiIwsx2+Lh7jmDnWN6cKdhjhSciSP6SqeYsCFXzFcGuiLy H20oGNUEmvhPkkjVh/UAGez2YFpCvSlIvMTN7kym/19s9QB8g/BNxwBCxIm7XQqAFGH8 N7kHPAmAHDbyci0L/kJcT1KCIV179P7ZhO8+9XgA2LsWVyrvbkKj11+PetGKfKtQypFa vudw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=JPO9ByPKmLGHIlVh9HNa1aojPSx0RjzMLohjZr9MFt0=; b=Jk8aZtCoCqVOriQC4wx1yC9/RR2MYq1Noit/WbvD9ZYZ7BEcxWOkb6BzqRzBG6jWp4 bWJPpR8RbnRxDuNU1fb9876LBqXheHWvlOvwrrav8NHJvyyoEy4jE+SrRbaN5+eK/r/G jypTLior6HjL89qttyavWAbym9B4uO5wIg3Bl3KQeD1g6qpECB/TP9uZI/A7/e4h4Gfv l7dDUZLk6YtTPndIw2CkZLwyFipkqoEiIvPdlQIgQVr+BpZ9NkdNOfRl4uOqI8b3uwkp HmAf6EzGFS9BfeW3MiET8zBDrdDUvf0feNMWe2jvumZZAtLO8YcwZI2NE0Va5Auj6J2n MoCg== X-Gm-Message-State: AKGB3mK2+VIa5tCcPOEbiRAD1UHiNoZxWYFgC6I2eSoVK6nXyhC9Rx71 92SWfb2W6plxJCDGrq/xR4bq5B2MNgektVh+n04= X-Google-Smtp-Source: AGs4zMYAUrvBvRrIY8OCg4q5E/Vt9tsR59YGCoS2HJn9oynlwz4STMKJbpZppHUJcxmUBnqPagAL8cVw4DrUsj2rw9Q= X-Received: by 10.237.48.193 with SMTP id 59mr3778868qtf.45.1512540957997; Tue, 05 Dec 2017 22:15:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.19.4 with HTTP; Tue, 5 Dec 2017 22:15:17 -0800 (PST) In-Reply-To: <2090.1512532919@sss.pgh.pa.us> References: <17868.1512519318@sss.pgh.pa.us> <2090.1512532919@sss.pgh.pa.us> From: amul sul Date: Wed, 6 Dec 2017 11:45:17 +0530 Message-ID: Subject: Re: pgsql: Support Parallel Append plan nodes. To: Tom Lane Cc: Robert Haas , pgsql-committers@postgresql.org Content-Type: multipart/mixed; boundary="94eb2c0c34f6829cbd055fa5e220" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --94eb2c0c34f6829cbd055fa5e220 Content-Type: text/plain; charset="UTF-8" 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 Regards, Amul On Wed, Dec 6, 2017 at 9:31 AM, Tom Lane wrote: > 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)", File: "nodeAppend.c", Line: 520) > 2017-12-05 22:50:38.211 EST [28158] LOG: background worker "parallel worker" (PID 28818) was terminated by signal 6: Abort trap > 2017-12-05 22:50:38.211 EST [28158] DETAIL: Failed process was running: select 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: whichplan -1, nextplan -1, fpp 0, nplans 6 > 2017-12-05 22:42:24.187 EST [843] STATEMENT: select round(avg(aa)), sum(aa) from a_star a1; > 2017-12-05 22:42:24.188 EST [844] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 0, nplans 6 > 2017-12-05 22:42:24.188 EST [844] STATEMENT: select round(avg(aa)), sum(aa) from a_star a1; > 2017-12-05 22:42:24.188 EST [845] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 0, nplans 6 > 2017-12-05 22:42:24.188 EST [845] STATEMENT: select round(avg(aa)), sum(aa) from a_star a1; > 2017-12-05 22:42:24.197 EST [846] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 2, nplans 6 > 2017-12-05 22:42:24.197 EST [846] STATEMENT: select round(avg(aa)), sum(aa) from a_star a2; > 2017-12-05 22:42:24.200 EST [847] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 2, nplans 6 > 2017-12-05 22:42:24.200 EST [847] STATEMENT: select round(avg(aa)), sum(aa) from a_star a2; > 2017-12-05 22:42:24.200 EST [848] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 2, nplans 6 > 2017-12-05 22:42:24.200 EST [848] STATEMENT: select round(avg(aa)), sum(aa) from a_star a2; > 2017-12-05 22:42:24.214 EST [849] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 6, nplans 6 > 2017-12-05 22:42:24.214 EST [849] STATEMENT: select round(avg(aa)), sum(aa) from a_star a3; > 2017-12-05 22:42:24.214 EST [852] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 6, nplans 6 > 2017-12-05 22:42:24.214 EST [852] STATEMENT: select round(avg(aa)), sum(aa) from a_star a3; > 2017-12-05 22:42:24.214 EST [853] LOG: choose_next_subplan_for_worker: whichplan -1, nextplan -1, fpp 6, nplans 6 > 2017-12-05 22:42:24.214 EST [853] STATEMENT: select round(avg(aa)), sum(aa) 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 > --94eb2c0c34f6829cbd055fa5e220 Content-Type: application/octet-stream; name="Parallel-Append-crash-fix.patch" Content-Disposition: attachment; filename="Parallel-Append-crash-fix.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_jaunobwx1 RnJvbSA5YTc4NTMxNDE4M2FmMDMzOWEwYmU4OGRjYzkyNDVkMjRlOGQ5ODE4IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbXVsIFN1bCA8c3VsYW11bEBnbWFpbC5jb20+CkRhdGU6IFdl ZCwgNiBEZWMgMjAxNyAxMDoyMjoyMCArMDUzMApTdWJqZWN0OiBbUEFUQ0hdIFBhcmFsbGVsIEFw cGVuZCBjcmFzaCBmaXgKCkZpeGVzIHRoZSBjcmFzaCBvbiBidWlsZmFybVsxXQoKVGhlIHJlYXNv biBiZWhpbmQgdGhlIGNyYXNoIGlzIHRoZSBzYW1lIHRoYXQgd2UgaGFkIGRpc2N1c3NlZCBiZWZv cmVbMl0KYnV0IHRoaXMgdGltZSBjcmFzaCBpcyBkdWUgdG8gYXNzZXJ0IHRoYXQgSSd2ZSBhZGRl ZCBpbiB0aGUgYXNzdW1wdGlvbgp0aGF0I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