Re: BUG #14150: Attempted to delete invisible tuple

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Oskari Saarenmaa <os(at)aiven(dot)io>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Peter Tripp <peter(at)chartio(dot)com>, Virendra Negi <virendra(at)idyllic-software(dot)com>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14150: Attempted to delete invisible tuple
Date: 2016-07-06 23:07:38
Message-ID: CAM3SWZTBsp2E3vdJoLY3v5fnao+kqcgSR14RqKe7JBLBUBmi8g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Jul 6, 2016 at 3:30 AM, Oskari Saarenmaa <os(at)aiven(dot)io> wrote:
>> ISTM this is caused by toast knowing nothing about speculative
>> insertion: when two backends have executed a speculative heap_insert
>> with a conflicting key and the latter one tries to abort after receiving
>> specConflict there's nothing in tqual.c to say that the toast rows
>> associated with speculative insertion should be visible to that operation.
>
>
> The attached patch against current master allows heap_abort_speculative to
> delete toast rows created by the same command which makes the above test
> case and "make check" run without failures. Note that I haven't touched
> this code before so I don't know how safe my patch is.

I don't really understand your explanation of what this patch does.
Obviously heap_abort_speculative() often has no apparent problem with
any of this; this bug involves a relatively rare race condition
scenario where there *is* a problem. We didn't simply neglect to make
heap_abort_speculative() consider TOAST at all, though.

My sense is that the problem occurs before Postgres throw this
"attempted to delete invisible tuple", and that a better fix is one
that prevents that condition from occurring in the first place
according to the extant visibility rules for
HeapTupleSatisfiesUpdate(). I'm not sure that your fix has not merely
masked the issue.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2016-07-06 23:33:36 Re: BUG #14150: Attempted to delete invisible tuple
Previous Message Andrew Gierth 2016-07-06 22:43:16 Re: BUG #14231: logical replication wal sender process spins when using error traps in function