Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items - Mailing list pgsql-hackers

From James Coleman
Subject Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items
Date
Msg-id CAAaqYe9_zOWeqgfT2rPo+SM1zw7-ebHbBceJzyh0zhPBkf9-7w@mail.gmail.com
Whole thread Raw
In response to Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
On Thu, Apr 9, 2020 at 3:05 PM Peter Geoghegan <pg@bowt.ie> wrote:
>
> On Wed, Apr 8, 2020 at 10:56 PM Masahiko Sawada
> <masahiko.sawada@2ndquadrant.com> wrote:
> > Here is the reproducer:
>
> What version of Postgres did you notice the actual customer issue on?
> I ask because I wonder if the work on B-Tree indexes in Postgres 12
> affects the precise behavior you get here with real world workloads.
> It probably makes _bt_killitems() more effective with some workloads,
> which naturally increases the likelihood of having multiple FPI issued
> in the manner that you describe. OTOH, it might make it less likely
> with low cardinality indexes, since large groups of garbage duplicate
> tuples tend to get concentrated on just a few leaf pages.

We saw the issue on our PG11 clusters. The specific index we noticed
in the wal dump (I don't think we confirmed if there were others) as
one on a `created_at` column, to give you an idea of cardinality.

> > The inner test in the comment "found the item" never tests the item
> > for being dead. So maybe we can add !ItemIdIsDead(iid) to that
> > condition. But there still is a race condition of recording multiple
> > FPIs can happen. Maybe a better solution is to change the lock to
> > exclusive, at least when wal_log_hints = on, so that only one process
> > can run this code -- the reduction in concurrency might be won back by
> > the fact that we don't wal-log the page multiple times.
>
> I like the idea of checking !ItemIdIsDead(iid) as a further condition
> of killing the item -- there is clearly no point in doing work to kill
> an item that is already dead. I don't like the idea of using an
> exclusive buffer lock (even if it's just with wal_log_hints = on),
> though.

I don't have a strong opinion on the lock.

James



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: where should I stick that backup?
Next
From: Justin Pryzby
Date:
Subject: Re: debian bugrept involving fast default crash in pg11.7