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: Thomas Munro <thomas.munro@gmail.com>
Cc: Kamigishi Rei <iijima.yun@koumakan.jp>
Cc: David Rowley <dgrowley@gmail.com>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17245: Index corruption involving deduplicated entries
Date: Thu, 28 Oct 2021 18:19:23 -0700
Message-ID: <20211029011923.utmolntkasenzreh@alap3.anarazel.de> (raw)
In-Reply-To: <CAH2-Wz=k-Gh3ANkpxvK9+XJqAQVEySPu08w2KYfnUKwHPqFrgw@mail.gmail.com>
References: <9076c0bd-e238-5f8d-1117-7f5549e35c33@koumakan.jp>
	<CAH2-Wzm0GZnNgNeHx-W-4ogR1RB1gGk_efMiWuinXFyMWzjb=w@mail.gmail.com>
	<CAH2-WznotEY2YXLBA44oqWLtQUTYHAKWnujCWmmWgthKhZ-97w@mail.gmail.com>
	<4c0d2dff-9fa2-1db0-0d0f-c84aefddfaab@koumakan.jp>
	<CAH2-Wz=s5EMTPeXYO9vS9Pdtq8UkY77qAdmEQ4sL1UMODK8zEA@mail.gmail.com>
	<20211028213103.vkmdhx447clb6ph6@alap3.anarazel.de>
	<CA+hUKGLtrpQnOQpBvJXQX+o2NJJ47Rmu=qt+F3tdhwCaaEoa9Q@mail.gmail.com>
	<CAH2-WzkOx5YjpjYB7iW32CF+-zTh1H4HarhzHoqVeacU0J2+pA@mail.gmail.com>
	<20211028224831.bj7ew3j74tw4cmvh@alap3.anarazel.de>
	<CAH2-Wz=k-Gh3ANkpxvK9+XJqAQVEySPu08w2KYfnUKwHPqFrgw@mail.gmail.com>

Hi,

It's not the cause of this problem, but I did find a minor issue: the retry
path in lazy_scan_prune() looses track of the deleted tuple count when
retrying.

The retry codepath also made me wonder if there could be problems if we do
FreezeMultiXactId() multiple times due to retry. I think we can end up
creating multiple multixactids for the same tuple (if the members change,
which is likely in the retry path). But that should be fine, I think.


On 2021-10-28 16:04:44 -0700, Peter Geoghegan wrote:
> > Didn't 14 change the logic when index vacuums are done? That could cause
> > previously existing issues to manifest with a higher likelihood.
>
> I don't follow. The new logic that skips index vacuuming kicks in 1)
> in an anti-wraparound vacuum emergency, and 2) when there are very few
> LP_DEAD line pointers in the heap. We can rule 1 out, I think, because
> the XIDs we see are in the low millions, and our starting point was a
> database that was upgraded via a dump and reload.

Right.


> The second criteria for skipping index vacuuming (the "less than 2% of
> heap pages have any LP_DEAD items" thing) might well have been hit on
> these tables -- it is after all very common. But I don't see how that
> could matter. We're never going to get to a code path inside
> vacuumlazy.c that sets LP_DEAD items from VACUUM's dead_tuples array
> to LP_UNUSED (how could reached such a code path without also index
> vacuuming, given the way things are set up inside lazy_vacuum()?).
> We're always going to have the opportunity to do index vacuuming with
> any left-behind LP_DEAD line pointers in the next VACUUM -- right
> after the later VACUUM successfully returns from
> lazy_vacuum_all_indexes().

Shrug. It doesn't seem that hard to believe that repeatedly trying to prune
the same page could unearth some bugs. E.g. via the heap_prune_record_unused()
path in heap_prune_chain().

Hm. I assume somebody checked and verified that old_snapshot_threshold is not
in use? Seems unlikely, but wrongly entering that heap_prune_record_unused()
path could certainly cause issues like we're observing.

Greetings,

Andres Freund





view thread (103+ messages)  latest in thread

Message-ID: <20211029011923.utmolntkasenzreh@alap3.anarazel.de>
Permalink:  ../20211029011923.utmolntkasenzreh@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20211029011923.utmolntkasenzreh@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, thomas.munro@gmail.com, iijima.yun@koumakan.jp, dgrowley@gmail.com, andrew@tao11.riddles.org.uk
  Subject: Re: BUG #17245: Index corruption involving deduplicated entries
  In-Reply-To: <20211029011923.utmolntkasenzreh@alap3.anarazel.de>
  References: <9076c0bd-e238-5f8d-1117-7f5549e35c33@koumakan.jp> <CAH2-Wzm0GZnNgNeHx-W-4ogR1RB1gGk_efMiWuinXFyMWzjb=w@mail.gmail.com> <CAH2-WznotEY2YXLBA44oqWLtQUTYHAKWnujCWmmWgthKhZ-97w@mail.gmail.com> <4c0d2dff-9fa2-1db0-0d0f-c84aefddfaab@koumakan.jp> <CAH2-Wz=s5EMTPeXYO9vS9Pdtq8UkY77qAdmEQ4sL1UMODK8zEA@mail.gmail.com> <20211028213103.vkmdhx447clb6ph6@alap3.anarazel.de> <CA+hUKGLtrpQnOQpBvJXQX+o2NJJ47Rmu=qt+F3tdhwCaaEoa9Q@mail.gmail.com> <CAH2-WzkOx5YjpjYB7iW32CF+-zTh1H4HarhzHoqVeacU0J2+pA@mail.gmail.com> <20211028224831.bj7ew3j74tw4cmvh@alap3.anarazel.de> <CAH2-Wz=k-Gh3ANkpxvK9+XJqAQVEySPu08w2KYfnUKwHPqFrgw@mail.gmail.com> <20211029011923.utmolntkasenzreh@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