Re: GiST VACUUM
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Thomas Munro <thomas.munro@gmail.com>,
Michael Paquier <michael@paquier.xyz>
Cc: Andrey Borodin <x4mmm@yandex-team.ru>, Thomas Munro <thomas.munro@enterprisedb.com>, Robert Haas <robertmhaas@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>, Костя Кузнецов <chapaev28@ya.ru>
Date: 2019-06-27T11:38:47Z
Lists: pgsql-hackers
Attachments
- 0001-Refactor-checks-for-deleted-GiST-pages.patch (text/x-patch)
On 26/06/2019 06:07, Thomas Munro wrote: > On Wed, Jun 26, 2019 at 2:33 PM Michael Paquier <michael@paquier.xyz> wrote: >> On Tue, Jun 25, 2019 at 02:38:43PM +0500, Andrey Borodin wrote: >>> I feel a little uncomfortable with number 0x7fffffff right in code. >> >> PG_INT32_MAX... > > MaxTransactionId / 2? Yeah, that makes sense. Here's a new version of the patches. Changes: * I changed the reuse-logging so that we always write a reuse WAL record, even if the deleteXid is very old. I tried to avoid that with the check for MaxTransactionId / 2 or 0x7fffffff, but it had some problems. In the previous patch version, it wasn't just an optimization. Without the check, we would write 32-bit XIDs to the log that had already wrapped around, and that caused the standby to unnecessarily wait for or kill backends. But checking for MaxTransaction / 2 isn't quite enough: there was a small chance that the next XID counter advanced just after checking for that, so that we still logged an XID that had just wrapped around. A more robust way to deal with this is to log a full 64-bit XID, and check for wraparound at redo in the standby. And if we do that, trying to optimize this in the master doesn't seem that important anymore. So in this patch version, we always log the 64-bit XID, and check for the MaxTransaction / 2 when replaying the WAL record instead. * I moved the logic to extend a 32-bit XID to 64-bits to a new helper function in varsup.c. * Instead of storing just a naked FullTransactionId in the "page contents" of a deleted page, I created a new struct for that. The effect is the same, but I think the struct clarifies what's happening, and it's a good location to attach a comment explaining it. * Fixed the mixup between < and > I haven't done any testing on this yet. Andrey, would you happen to have an environment ready to test this? - Heikki
Commits
-
Use full 64-bit XID for checking if a deleted GiST page is old enough.
- fb5344c969af 12.0 landed
- 6655a7299d83 13.0 landed
-
Refactor checks for deleted GiST pages.
- e2e992c93145 12.0 landed
- 9eb5607e6993 13.0 landed
-
Delete empty pages during GiST VACUUM.
- 7df159a620b7 12.0 landed
-
Scan GiST indexes in physical order during VACUUM.
- fe280694d0d4 12.0 landed
-
Prevent GIN deleted pages from being reclaimed too early
- 52ac6cd2d0cd 12.0 cited