Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csGRm-0004s6-47 for pgsql-hackers@arkaria.postgresql.org; Sun, 26 Mar 2017 22:15:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1csGRl-0006Io-N7 for pgsql-hackers@arkaria.postgresql.org; Sun, 26 Mar 2017 22:15: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 1csGQF-00039q-Pb for pgsql-hackers@postgresql.org; Sun, 26 Mar 2017 22:14:03 +0000 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1csGQB-0001EK-At for pgsql-hackers@postgresql.org; Sun, 26 Mar 2017 22:14:02 +0000 Received: by mail-wr0-x233.google.com with SMTP id l43so31001212wre.1 for ; Sun, 26 Mar 2017 15:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=LxJ/jU70JgsDl5P/DWe1K8CDU/2lcLcYR/ZDvjQzs5o=; b=0ly43HGcViMV3xJebmv4HkKJio1c24+Zz1+FA7pY7HQlrp2fy/u5exSnZ3847bd5xo rb/62bpH59RvUqsrCh3vGdwxnKwkcXib9VNGPRwaccvGANdWtpuCvakOR1dVBGG/Mmly HbamR+pe3TfLQh5/B93mlWN1D6Cy0bmU5KY1NdZjN4NvDF4yzjg5oQ+C3eFse+X9x8Nc 1S10ys69S1kdT84TWjKI21kB/XXMoYOEUhN9PkMUtDg139V51aX1GEQKUngVRaKr7von UeyiFOjbQMGHXaiVc+Fwa7oomqm5ZIkPyAk+ogWuZlB8HlnCn1IRsW+FCl/g9AyC4lcE LYlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=LxJ/jU70JgsDl5P/DWe1K8CDU/2lcLcYR/ZDvjQzs5o=; b=DTSTjE82bIKiwJHVUvhpjOYWKJLPQHEN24aug68TtLsaNr2rcS6U63fMtAqRQEki9R y1mkOBVzsR6XaGe1nImGLssCYPoUAyP7IAxh9XYZkI+SypveXJp7JFUQH9y2+1YeHDfn TWu2gZoMcN4UVfEAxALbtqJI5FXC5R4k564RUq7/6oZ9YD8SUY2Ni5bMGc6XBdrhfbuE xvHEHXdk9op6psJCqFbmIP+X7otI0sXbXaOAeoyGsXWFGgY7jn+Cyb8lbD+p3iGJRRhb HVnp3r9isE99AFrKThzEmMkVxMix/TWpPXRvxaTOESMmIpXrSCGycmGBzfFLKcwZwVbm 1eGA== X-Gm-Message-State: AFeK/H0NABmIdrol/wQicG52t8IbTY2inQDzNYYFut5+oivybUIxrGbtPj/s6ogJNW+2z+Vf X-Received: by 10.223.164.6 with SMTP id d6mr2342595wra.132.1490566437880; Sun, 26 Mar 2017 15:13:57 -0700 (PDT) Received: from [10.137.2.17] (ip-89-177-46-65.net.upcbroadband.cz. [89.177.46.65]) by smtp.gmail.com with ESMTPSA id g78sm12329147wrd.11.2017.03.26.15.13.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Mar 2017 15:13:57 -0700 (PDT) Subject: Re: crashes due to setting max_parallel_workers=0 To: Rushabh Lathia , Peter Eisentraut References: <6ecd6f17-0dcf-1de7-ded8-0de7db1ddc88@2ndquadrant.com> Cc: David Rowley , PostgreSQL-development , Robert Haas From: Tomas Vondra Message-ID: Date: Mon, 27 Mar 2017 00:13:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 03/25/2017 05:18 PM, Rushabh Lathia wrote: > > > On Sat, Mar 25, 2017 at 7:01 PM, Peter Eisentraut > > wrote: > > On 3/25/17 09:01, David Rowley wrote: > > On 25 March 2017 at 23:09, Rushabh Lathia > wrote: > >> Also another point which I think we should fix is, when someone set > >> max_parallel_workers = 0, we should also set the > >> max_parallel_workers_per_gather > >> to zero. So that way it we can avoid generating the gather path with > >> max_parallel_worker = 0. > > I see that it was actually quite useful that it works the way it does. > > If it had worked the same as max_parallel_workers_per_gather, then > > likely Tomas would never have found this bug. > > Another problem is that the GUC system doesn't really support cases > where the validity of one setting depends on the current value of > another setting. So each individual setting needs to be robust against > cases of related settings being nonsensical. > > > Okay. > > About the original issue reported by Tomas, I did more debugging and > found that - problem was gather_merge_clear_slots() was not returning > the clear slot when nreader is zero (means nworkers_launched = 0). > Due to the same scan was continue even all the tuple are exhausted, > and then end up with server crash at gather_merge_getnext(). In the patch > I also added the Assert into gather_merge_getnext(), about the index > should be less then the nreaders + 1 (leader). > > PFA simple patch to fix the problem. > I think there are two issues at play, here - the first one is that we still produce parallel plans even with max_parallel_workers=0, and the second one is the crash in GatherMerge when nworkers=0. Your patch fixes the latter (thanks for looking into it), which is obviously a good thing - getting 0 workers on a busy system is quite possible, because all the parallel workers can be already chewing on some other query. But it seems a bit futile to produce the parallel plan in the first place, because with max_parallel_workers=0 we can't possibly get any parallel workers ever. I wonder why compute_parallel_worker() only looks at max_parallel_workers_per_gather, i.e. why shouldn't it do: parallel_workers = Min(parallel_workers, max_parallel_workers); Perhaps this was discussed and is actually intentional, though. Regarding handling this at the GUC level - I agree with Peter that that's not a good idea. I suppose we could deal with checking the values in the GUC check/assign hooks, but what we don't have is a way to undo the changes in all the GUCs. That is, if I do SET max_parallel_workers = 0; SET max_parallel_workers = 16; I expect to end up with just max_parallel_workers GUC changed and nothing else. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers