Re: pg14b1 stuck in lazy_scan_prune/heap_page_prune of pg_statistic
Matthias van de Meent <boekewurm+postgres@gmail.com>
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Peter Geoghegan <pg@bowt.ie>, Justin Pryzby <pryzby@telsasoft.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Masahiko Sawada <sawada.mshk@gmail.com>, Andres Freund <andres@anarazel.de>,
Tom Lane <tgl@sss.pgh.pa.us>
Date: 2021-06-09T15:42:34Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fix-a-bug-in-GetOldestNonRemovableTransactionId.patch (text/x-patch) patch v1-0001
On Wed, 9 Jun 2021 at 04:42, Michael Paquier <michael@paquier.xyz> wrote: > > On Tue, Jun 08, 2021 at 05:47:28PM -0700, Peter Geoghegan wrote: > > I don't have time to try this out myself today, but offhand I'm pretty > > confident that this is sufficient to reproduce the underlying bug > > itself. And if that's true then I guess it can't have anything to do > > with the pg_upgrade/pg_resetwal issue Tom just referenced, despite the > > apparent similarity. > > Agreed. It took me a couple of minutes to get autovacuum to run in an > infinite loop with a standalone instance. Nice catch, Justin! I believe that I've found the culprit: GetOldestNonRemovableTransactionId(rel) does not use the exact same conditions for returning OldestXmin as GlobalVisTestFor(rel) does. This results in different minimal XIDs, and subsequently this failure. The attached patch fixes this inconsistency, and adds a set of asserts to ensure that GetOldesNonRemovableTransactionId is equal to the maybe_needed of the GlobalVisTest of that relation, plus some at GlobalVisUpdateApply such that it will fail whenever it is called with arguments that would move the horizons in the wrong direction. Note that there was no problem in GlobalVisUpdateApply, but it helped me determine that that part was not the source of the problem, and I think that having this safeguard is a net-positive. Another approach might be changing GlobalVisTestFor(rel) instead to reflect the conditions in GetOldestNonRemovableTransactionId. With attached prototype patch, I was unable to reproduce the problematic case in 10 minutes. Without, I got the problematic behaviour in seconds. With regards, Matthias
Commits
-
Deduplicate choice of horizon for a relation procarray.c.
- 3d0a4636aa4c 14.0 landed
- d9d8aa9bb9aa 15.0 landed
-
Use correct horizon when vacuuming catalog relations.
- 5a1e1d83022b 14.0 landed
-
Truncate line pointer array during VACUUM.
- 3c3b8a4b2689 14.0 cited
-
Remove tupgone special case from vacuumlazy.c.
- 8523492d4e34 14.0 cited
-
Refactor lazy_scan_heap() loop.
- 7ab96cf6b312 14.0 cited
-
snapshot scalability: Don't compute global horizons while building snapshots.
- dc7420c2c927 14.0 cited