dbTalk Databases Forums  

Re: [BUGS] Segfault in backend CTE code

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] Segfault in backend CTE code in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Segfault in backend CTE code - 01-23-2012 , 11:43 PM






Phil Sorber <phil (AT) omniti (DOT) com> writes:
Quote:
I've attached a backtrace.
How about a test case? I have no faith in the proposed patch without
some evidence of what it's supposed to fix.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Segfault in backend CTE code - 01-24-2012 , 03:03 PM






Phil Sorber <phil (AT) omniti (DOT) com> writes:
Quote:
On Tue, Jan 24, 2012 at 12:43 AM, Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> wrote:
How about a test case?

We are having trouble coming up with a test case that can reliably
reproduce this.
The stack traces run through the EvalPlanQual machinery, which is only
going to be entered when attempting to update/delete a row that's been
updated by a concurrent transaction. So what I'd suggest for creating a
test case is

(1) in a psql session, do
BEGIN;
UPDATE some-target-row;

(2) in another psql session, call this function with arguments
that will make it try to update that same row; it should
block.

(3) in the first session, COMMIT to unblock.

FWIW, having re-examined your patch with some caffeine in me, I don't
think it's right at all. You can't just blow off setting the scan type
for a CTEScan node. What it looks like to me is that the EvalPlanQual
code is not initializing the new execution tree correctly; but that
idea would be a lot easier to check into with a test case.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Segfault in backend CTE code - 01-25-2012 , 04:13 PM



Phil Sorber <phil (AT) omniti (DOT) com> writes:
Quote:
That helped a lot. I now have a simple test case that I can reliably
re-produce the segfault and now also a patch that fixes it.
[ pokes at that... ] Hmm. I think what this proves is that that
optimization in EvalPlanQualStart is just too cute for its own good,
and that the only safe fix is to take it out. That code path is
(obviously) none too well tested, so we should not have it setting
up execution tree structures that are not like those used normally.
It's just begging for trouble.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
  #4  
Old   
Phil Sorber
 
Posts: n/a

Default Re: [BUGS] Segfault in backend CTE code - 01-27-2012 , 02:02 PM



On Wed, Jan 25, 2012 at 5:13 PM, Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> wrote:
Quote:
Phil Sorber <phil (AT) omniti (DOT) com> writes:
That helped a lot. I now have a simple test case that I can reliably
re-produce the segfault and now also a patch that fixes it.

[ pokes at that... ] *Hmm. *I think what this proves is that that
optimization in EvalPlanQualStart is just too cute for its own good,
and that the only safe fix is to take it out. *That code path is
(obviously) none too well tested, so we should not have it setting
up execution tree structures that are not like those used normally.
It's just begging for trouble.
I played around with removing the optimization, but there are other
pieces further down the line that are upset but having a ModifyTable
node in the execution tree. Specifically this:

http://git.postgresql.org/gitweb/?p=...232 9d4f#l900

Not sure at all how to proceed from there so I am deferring. Perhaps
the original authors can be asked to weigh in? We changed our writable
CTE queries to update/insert loops so this is no longer a blocker for
us.

Quote:
* * * * * * * * * * * *regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
  #5  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Segfault in backend CTE code - 01-28-2012 , 04:59 PM



Phil Sorber <phil (AT) omniti (DOT) com> writes:
Quote:
On Wed, Jan 25, 2012 at 5:13 PM, Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> wrote:
I played around with removing the optimization, but there are other
pieces further down the line that are upset but having a ModifyTable
node in the execution tree.
Hm, yeah, obviously this scenario has never been tested :-(. I have
applied a patch for it, and also done some work so that it will get
tested by the buildfarm in future. Thanks for the report!

Quote:
We changed our writable CTE queries to update/insert loops so this is
no longer a blocker for us.
FWIW, that technique didn't really work anyway, as even with the patch
I observe that you get a "duplicate unique key" failure if two such
commands try to insert a new row concurrently. This is because neither
UPDATE subquery will see an as-yet-uncommitted inserted row.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.