From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Race between KeepFileRestoredFromArchive() and restartpoint |
Date: | 2021-06-19 20:39:18 |
Message-ID: | 20210619203918.GA1189385@rfd.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Feb 02, 2021 at 07:14:16AM -0800, Noah Misch wrote:
> Recycling and preallocation are wasteful during archive recovery, because
> KeepFileRestoredFromArchive() unlinks every entry in its path. I propose to
> fix the race by adding an XLogCtl flag indicating which regime currently owns
> the right to add long-term pg_wal directory entries. In the archive recovery
> regime, the checkpointer will not preallocate and will unlink old segments
> instead of recycling them (like wal_recycle=off). XLogFileInit() will fail.
Here's the implementation. Patches 1-4 suffice to stop the user-visible
ERROR. Patch 5 avoids a spurious LOG-level message and wasted filesystem
writes, and it provides some future-proofing.
I was tempted to (but did not) just remove preallocation. Creating one file
per checkpoint seems tiny relative to the max_wal_size=1GB default, so I
expect it's hard to isolate any benefit. Under the old checkpoint_segments=3
default, a preallocated segment covered a respectable third of the next
checkpoint. Before commit 63653f7 (2002), preallocation created more files.
Attachment | Content-Type | Size |
---|---|---|
XLogFileInit1-use_lock-v1.patch | text/plain | 6.9 KB |
XLogFileInit2-redefine-use_existent-v1.patch | text/plain | 1.8 KB |
XLogFileInit3-write-only-use_existent-v1.patch | text/plain | 6.4 KB |
XLogFileInit4-PreallocXlogFiles-v1.patch | text/plain | 7.7 KB |
XLogFileInit5-lock-v1.patch | text/plain | 7.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Korotkov | 2021-06-20 01:12:56 | Re: unnesting multirange data types |
Previous Message | AJG | 2021-06-19 20:38:58 | Re: a path towards replacing GEQO with something better |