pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum
Date: Wed, 10 Nov 2021 16:57:03 -0800
Message-ID: <20211111005703.3alukwc33cn3uiu5@alap3.anarazel.de> (raw)
In-Reply-To: <CAH2-Wzm+sFTB40jCYGdKDF8RoREtEvSdanF-nzyzugr2gdPALQ@mail.gmail.com>
References: <20211030213948.3i3f7cieqxzhd7kq@alap3.anarazel.de>
	<20211031192051.e3r2uxft3bulymrr@localhost>
	<08c2445c-c3c9-ba45-18d3-6399707d8306@gmail.com>
	<20211108172852.pvsarxoxi54uatch@localhost>
	<CAH2-Wzka8u1Y+GNP41TQiHjLMP7mYG9h3i+5jq-FzSKgWXBk+Q@mail.gmail.com>
	<20211109150216.fgfybn35mwnkeef3@localhost>
	<CAH2-Wzma=Y3O+LRx2Wj_HwGbbbeNwr6FoJzXni8hxOMw55pcZg@mail.gmail.com>
	<CAH2-WznNKY6ydUczuTXutVmb_dj3MnAcoaVYc8xyignWfNQ=FQ@mail.gmail.com>
	<20211110192010.ckvfzz352hsba5xf@alap3.anarazel.de>
	<CAH2-Wzm+sFTB40jCYGdKDF8RoREtEvSdanF-nzyzugr2gdPALQ@mail.gmail.com>

Hi,

On 2021-11-10 14:18:01 -0800, Peter Geoghegan wrote:
> On Wed, Nov 10, 2021 at 11:20 AM Andres Freund <andres@anarazel.de> wrote:
> > I hit a crash once in 13 with a slightly evolved version of the test (many
> > connections creating / dropping the partitions as in the original scenario,
> > using :client_id to target different tables). It's possible that my
> > instrumentation was the cause of that. Unfortunately it took quite a few hours
> > to hit the problem in 13...
> 
> Have you thought about the case where a transaction does a HOT update
> of the same row twice, and then aborts?

Yes. I don't think it's problematic right now, because the redirect would, I
think, in all cases have to point to the chain element before those tuples,
because the preceding value would just have to be DELETE_IN_PROGRESS, which we
we don't follow in heap_prune_chain().


> I'm asking because I notice that the fragile "We need this primarily
> to handle aborted HOT updates" precheck for
> HeapTupleHeaderIsHeapOnly() doesn't just check if the heap-only tuple
> is DEAD before deciding to mark it LP_UNUSED. It also checks
> HeapTupleHeaderIsHotUpdated() against the target tuple -- that's
> another condition of the tuple being marked unused. Of course, whether
> or not a given tuple is considered HeapTupleHeaderIsHotUpdated() can
> change from true to false when an updater concurrently aborts. Could
> that have race conditions?

I wondered about that too, but I couldn't *quite* come up with a problematic
scenario, because I don't think any of the cases that can change
HeapTupleHeaderIsHotUpdated() would have allowed to set the redirect to a
subsequent chain element.


> In other words: what if the aforementioned "aborted HOT updates"
> precheck code doesn't deal with a DEAD tuple, imagining that it's not
> a relevant tuple, while at the same time the later HOT-chain-chasing
> code *also* doesn't get to the tuple? What if they each assume that
> the other will/has taken care of it, due to a race?

Then we'd just end up not pruning the tuple, I think. Which should be fine, as
it could only happen for fairly new tuples.

Greetings,

Andres Freund





view thread (90+ messages)  latest in thread

Message-ID: <20211111005703.3alukwc33cn3uiu5@alap3.anarazel.de>
Permalink:  ../20211111005703.3alukwc33cn3uiu5@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20211111005703.3alukwc33cn3uiu5@alap3.anarazel.de

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de, pg@bowt.ie, 9erthalion6@gmail.com, exclusion@gmail.com, boekewurm+postgres@gmail.com
  Subject: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum
  In-Reply-To: <20211111005703.3alukwc33cn3uiu5@alap3.anarazel.de>
  References: <20211030213948.3i3f7cieqxzhd7kq@alap3.anarazel.de> <20211031192051.e3r2uxft3bulymrr@localhost> <08c2445c-c3c9-ba45-18d3-6399707d8306@gmail.com> <20211108172852.pvsarxoxi54uatch@localhost> <CAH2-Wzka8u1Y+GNP41TQiHjLMP7mYG9h3i+5jq-FzSKgWXBk+Q@mail.gmail.com> <20211109150216.fgfybn35mwnkeef3@localhost> <CAH2-Wzma=Y3O+LRx2Wj_HwGbbbeNwr6FoJzXni8hxOMw55pcZg@mail.gmail.com> <CAH2-WznNKY6ydUczuTXutVmb_dj3MnAcoaVYc8xyignWfNQ=FQ@mail.gmail.com> <20211110192010.ckvfzz352hsba5xf@alap3.anarazel.de> <CAH2-Wzm+sFTB40jCYGdKDF8RoREtEvSdanF-nzyzugr2gdPALQ@mail.gmail.com> <20211111005703.3alukwc33cn3uiu5@alap3.anarazel.de>

* 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