Re: pg_upgrade failing for 200+ million Large Objects
Tharakan, Robins <tharar@amazon.com>
From: "Tharakan, Robins" <tharar@amazon.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2021-03-08T11:02:04Z
Lists: pgsql-hackers
Thanks Peter. The original email [1] had some more context that somehow didn't get associated with this recent email. Apologies for any confusion. In short, pg_resetxlog (and pg_resetwal) employs a magic constant [2] (for both v9.6 as well as master) which seems to have been selected to force an aggressive autovacuum as soon as the upgrade completes. Although that works as planned, it narrows the window of Transaction IDs available for the upgrade (before which XID wraparound protection kicks and aborts the upgrade) to 146 Million. Reducing this magic constant allows a larger XID window, which is what the patch is trying to do. With the patch, I was able to upgrade a cluster with 500m Large Objects successfully (which otherwise reliably fails). In the original email [1] I had also listed a few other possible workarounds, but was unsure which would be a good direction to start working on.... thus this patch to make a start. Reference: 1) https://www.postgresql.org/message-id/12601596dbbc4c01b86b4ac4d2bd4d48%40 EX13D05UWC001.ant.amazon.com 2) https://github.com/postgres/postgres/blob/master/src/bin/pg_resetwal/pg_r esetwal.c#L444 - robins | tharar@ | syd12 > -----Original Message----- > From: Peter Eisentraut <peter.eisentraut@enterprisedb.com> > Sent: Monday, 8 March 2021 9:25 PM > To: Tharakan, Robins <tharar@amazon.com>; pgsql-hackers@postgresql.org > Subject: [EXTERNAL] [UNVERIFIED SENDER] Re: pg_upgrade failing for 200+ > million Large Objects > > CAUTION: This email originated from outside of the organization. Do not > click links or open attachments unless you can confirm the sender and > know the content is safe. > > > > On 07.03.21 09:43, Tharakan, Robins wrote: > > Attached is a proof-of-concept patch that allows Postgres to perform > > pg_upgrade if the instance has Millions of objects. > > > > It would be great if someone could take a look and see if this patch > > is in the right direction. There are some pending tasks (such as > > documentation / pg_resetxlog vs pg_resetwal related changes) but for > > now, the patch helps remove a stalemate where if a Postgres instance > > has a large number (accurately speaking 146+ Million) of Large > > Objects, pg_upgrade fails. This is easily reproducible and besides > > deleting Large Objects before upgrade, there is no other (apparent) way > for pg_upgrade to complete. > > > > The patch (attached): > > - Applies cleanly on REL9_6_STABLE - > > c7a4fc3dd001646d5938687ad59ab84545d5d043 > > - 'make check' passes > > - Allows the user to provide a constant via pg_upgrade command-line, > > that overrides the 2 billion constant in pg_resetxlog [1] thereby > > increasing the (window of) Transaction IDs available for pg_upgrade to > complete. > > Could you explain what your analysis of the problem is and why this patch > (might) fix it? > > Right now, all I see here is, pass a big number via a command-line option > and hope it works.
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Count individual SQL commands in pg_restore's --transaction-size mode.
- 81db073a2878 17.0 landed
- 0f1290521504 18.0 landed
-
Reduce number of commands dumpTableSchema emits for binary upgrade.
- b3f0e0503f33 18.0 landed
- 2fa989e6a340 17.0 landed
-
Invent --transaction-size option for pg_restore.
- 959b38d770ba 17.0 landed
-
Rearrange pg_dump's handling of large objects for better efficiency.
- a45c78e3284b 17.0 landed
-
Add temporal PRIMARY KEY and UNIQUE constraints
- 46a0cd4cefb4 17.0 cited
-
Fix typo and case in messages
- 7d7ef075d2b3 17.0 cited