Re: BUG #14150: Attempted to delete invisible tuple

From: Andres Freund <andres(at)anarazel(dot)de>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Oskari Saarenmaa <os(at)aiven(dot)io>, 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:33:36
Message-ID: 20160706233336.irsrxqct3lc5vcwp@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2016-07-06 16:07:38 -0700, Peter Geoghegan wrote:
> 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.

Did you see oskari's reproducer in
http://archives.postgresql.org/message-id/88248a24-47d1-d575-a63f-2b56a09f82e2%40aiven.io
?

It's not really particularly hard to reproduce with that (pretty basic
interaction). Works like in 80% of the cases I tried, within less than a
sec.

> We didn't simply neglect to make heap_abort_speculative() consider
> TOAST at all, though.

Well, not quite, but nearly. Afaics it currently can only work if the
toasted columns have been inserted by a different command, before the
INSERT ON CONFLICT does anything. I don't see how it can work for newly
inserted toast data. When heap_abort_speculative deletes toast data,
when would it *ever* not fail if the same command executed the toast
data?

Andres

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2016-07-06 23:45:01 Re: BUG #14150: Attempted to delete invisible tuple
Previous Message Peter Geoghegan 2016-07-06 23:07:38 Re: BUG #14150: Attempted to delete invisible tuple