pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: luis.roberto@siscobra.com.br
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Cc: alan.formagi <alan.formagi@siscobra.com.br>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: James Coleman <jtc331@gmail.com>
Subject: Re: segfault with incremental sort
Date: Tue, 3 Nov 2020 14:06:08 -0300 (BRT)
Message-ID: <1332064613.40286998.1604423168236.JavaMail.zimbra@siscobra.com.br> (raw)
In-Reply-To: <924226.1604422326@sss.pgh.pa.us>
References: <622580997.37108180.1604080457319.JavaMail.zimbra@siscobra.com.br>
	<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>




Thanks for the test case! It looks like this issue is somewhat related 
to the "enable_incremental_sort changes query behavior" thread [1]. 
What I see happening is 

1. The SELECT DISTINCT gives rise to a sort key expression that 
contains non-parallel-safe SubPlans. (It's not immediately apparent 
to me why we don't consider these particular subqueries parallel safe, 
but they aren't. Anyway such a situation surely has to be allowed for.) 

2. The planner ignores the fact that the sort key isn't parallel-safe 
and makes a plan with IncrementalSort below Gather anyway. (I'm not 
certain that this bug is specific to IncrementalSort; but given the lack 
of previous complaints, I'm guessing we avoid this somehow for regular 
sorts.) 

3. ExecSerializePlan notes that the subplans aren't parallel-safe and 
doesn't send them to the workers. 

4. In the workers, nodeSubplan.c dumps core because the planstate it's 
expecting is not there. 

So, not only do we need to be thinking about volatility while checking 
whether IncrementalSort is possible, but also parallel-safety. 

In the meantime, now that I've seen this I don't have a lot of confidence 
that we'll never inject similar bugs in future. I'm thinking of 
committing the attached to at least reduce the stakes from "core dump" 
to "weird error message". 

regards, tom lane 




Thanks for confirming it. For now, disabling incremental sort will 'solve' the issue. I'll be keeping an eye on that thread. 

view thread (23+ messages)  latest in thread

Message-ID: <1332064613.40286998.1604423168236.JavaMail.zimbra@siscobra.com.br>
Permalink:  ../1332064613.40286998.1604423168236.JavaMail.zimbra@siscobra.com.br/
Also on:    postgresql.org/message-id/1332064613.40286998.1604423168236.JavaMail.zimbra@siscobra.com.br

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: luis.roberto@siscobra.com.br, tgl@sss.pgh.pa.us, pgsql-bugs@lists.postgresql.org, alan.formagi@siscobra.com.br, tomas.vondra@2ndquadrant.com, jtc331@gmail.com
  Subject: Re: segfault with incremental sort
  In-Reply-To: <1332064613.40286998.1604423168236.JavaMail.zimbra@siscobra.com.br>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox