pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Andrey Borodin <x4mmm@yandex-team.ru>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Петър Славов <pet.slavov@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY
Date: Tue, 24 May 2022 21:20:49 -0700
Message-ID: <20220525042049.7f24lsduwqujeims@alap3.anarazel.de> (raw)
In-Reply-To: <A5A99A74-268D-46E1-AD16-A880A9C55B0B@yandex-team.ru>
References: <CAH2-Wz=eJnkcLpgDhHzU=vz5Fu58HJxJB_Gt094Mx_L+6rD3_A@mail.gmail.com>
	<202205240902.bhkvu4lgljn3@alvherre.pgsql>
	<20220524163702.y2ct2gxk32zysxuf@alap3.anarazel.de>
	<20220524181542.cmec7rcv3vvvtze4@alap3.anarazel.de>
	<04B2AE56-C737-4F1E-ABEF-F88DA2280C5D@yandex-team.ru>
	<20220524190133.j6ee7zh4f5edt5je@alap3.anarazel.de>
	<A5A99A74-268D-46E1-AD16-A880A9C55B0B@yandex-team.ru>

Hi,

On 2022-05-25 09:00:47 +0500, Andrey Borodin wrote:
> > On 25 May 2022, at 00:01, Andres Freund <andres@anarazel.de> wrote:
> > 
> >>> On 24 May 2022, at 23:15, Andres Freund <andres@anarazel.de> wrote:
> >>> 
> >>> I suspect the problem might be related to pruning done during the validation
> >>> scan. Once PROC_IN_SAFE_IC is set, the backend itself will not preserve tids
> >>> its own snapshot might need. Which will wreak havoc during the validation
> >>> scan.
> >> 
> >> I observe that removing PROC_IN_SAFE_IC for index_validate() fixes tests.
> >> But why it's not a problem for index_build() scan?
> > 
> > I now suspect it's a problem for both, just more visible for index_validate().

> No, I understood now. index_build() in CIC can be safely replaced by
> index_build_empty().

I'm not convinced that that is true. I think at least for stuff like indexes
used in constraints (unique or exclusion) we need to do something like the
current approach.

But more importantly, there's a difference between not inserting any index
entries, and inserting entries based on a essentially corrupted
snapshot. Using a too old snapshot (which is what we have here) could lead to
all sorts of oddities when following HOT chains etc. Which might end up
inserting *too much* into the index, I think.


> So, can we leave the feature enabled for all the process besides index
> validation? We don't seem to need a valid snapshot in CIC anywhere else. Or
> it's safer to revert whole commit?

I doubt it's safe in the other places either. We can't just do a table scan,
which expects to be passed a valid snapshot, with a broken snapshot, and
expect no problems. At the very least I expect there to be a potential of
spurious warnings / errors.

Greetings,

Andres Freund





view thread (80+ messages)  latest in thread

Message-ID: <20220525042049.7f24lsduwqujeims@alap3.anarazel.de>
Permalink:  ../20220525042049.7f24lsduwqujeims@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20220525042049.7f24lsduwqujeims@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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de, x4mmm@yandex-team.ru, alvherre@alvh.no-ip.org, pg@bowt.ie, michael@paquier.xyz, pet.slavov@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY
  In-Reply-To: <20220525042049.7f24lsduwqujeims@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