Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ka1Lz-0002FP-0u for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Nov 2020 18:48:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ka1Lv-0000Rj-3V for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Nov 2020 18:48:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ka1Lu-0000Rc-Tr for pgsql-bugs@lists.postgresql.org; Tue, 03 Nov 2020 18:48:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ka1Ls-0001Nq-BR for pgsql-bugs@lists.postgresql.org; Tue, 03 Nov 2020 18:48:18 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0A3ImC0I961143; Tue, 3 Nov 2020 13:48:12 -0500 From: Tom Lane To: James Coleman cc: luis.roberto@siscobra.com.br, pgsql-bugs , "alan.formagi" , Tomas Vondra Subject: Re: segfault with incremental sort In-reply-to: References: <622580997.37108180.1604080457319.JavaMail.zimbra@siscobra.com.br> <102089.1604082122@sss.pgh.pa.us> <541187747.37582276.1604086719237.JavaMail.zimbra@siscobra.com.br> <107029.1604087483@sss.pgh.pa.us> <1673261949.37800156.1604090102715.JavaMail.zimbra@siscobra.com.br> <1807748588.37862034.1604091799640.JavaMail.zimbra@siscobra.com.br> <136656.1604092024@sss.pgh.pa.us> <1779929796.39206557.1604407053112.JavaMail.zimbra@siscobra.com.br> <924226.1604422326@sss.pgh.pa.us> Comments: In-reply-to James Coleman message dated "Tue, 03 Nov 2020 13:35:30 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <961141.1604429292.1@sss.pgh.pa.us> Date: Tue, 03 Nov 2020 13:48:12 -0500 Message-ID: <961142.1604429292@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk James Coleman writes: > On Tue, Nov 3, 2020 at 11:52 AM Tom Lane wrote: >> So, not only do we need to be thinking about volatility while checking >> whether IncrementalSort is possible, but also parallel-safety. > This is part of why I lean towards guessing it applies to regular sort > also (though haven't confirmed that): the new volatility (and if > volatile, then "expression is in target" checks just mirror existing > code pre-incremental sort. It's certainly possible that the bug exists for non-incremental sort but previously we'd not try to generate a plan that tripped over it. Anyway I do not recall seeing code that would specifically check for this. I think that, to the extent we've avoided it, it's because the sort key would normally be part of the reltarget list for some relation that would thereby get marked non-parallel-safe. Maybe the DISTINCT sort key never ends up in any reltarget list? > I also noticed that the incremental sort plan posted earlier has > multiple Gather Merge nodes; that's not what I would have expected, > but maybe I'm missing something. Hm. There is only one Gather Merge in the repro case. regards, tom lane