Re: WIP: WAL prefetch (another approach)
Thomas Munro <thomas.munro@gmail.com>
Attachments
- v14-0001-Add-pg_atomic_unlocked_add_fetch_XXX.patch (text/x-patch) patch v14-0001
- v14-0002-Improve-information-about-received-WAL.patch (text/x-patch) patch v14-0002
- v14-0003-Provide-XLogReadAhead-to-decode-future-WAL-recor.patch (text/x-patch) patch v14-0003
- v14-0004-Prefetch-referenced-blocks-during-recovery.patch (text/x-patch) patch v14-0004
- v14-0005-WIP-Avoid-extra-buffer-lookup-when-prefetching-W.patch (text/x-patch) patch v14-0005
On Sat, Nov 14, 2020 at 4:13 AM Stephen Frost <sfrost@snowman.net> wrote: > * Tomas Vondra (tomas.vondra@enterprisedb.com) wrote: > > On 11/13/20 3:20 AM, Thomas Munro wrote: > > > I'm not really sure what to do about achive restore scripts that > > > block. That seems to be fundamentally incompatible with what I'm > > > doing here. > > > > IMHO we can't do much about that, except for documenting it - if the > > prefetch can't work because of blocking restore script, someone has to > > fix/improve the script. No way around that, I'm afraid. > > I'm a bit confused about what the issue here is- is the concern that a > restore_command is specified that isn't allowed to run concurrently but > this patch is intending to run more than one concurrently..? There's > another patch that I was looking at for doing pre-fetching of WAL > segments, so if this is also doing that we should figure out which > patch we want.. The problem is that the recovery loop tries to look further ahead in between applying individual records, which causes the restore script to run, and if that blocks, we won't apply records that we already have, because we're waiting for the next WAL file to appear. This behaviour is on by default with my patch, so pg_standby will introduce a weird replay delays. We could think of some ways to fix that, with meaningful return codes and periodic polling or something, I suppose, but something feels a bit weird about it. > I don't know that it's needed, but it feels likely that we could provide > a better result if we consider making changes to the restore_command API > (eg: have a way to say "please fetch this many segments ahead, and you > can put them in this directory with these filenames" or something). I > would think we'd be able to continue supporting the existing API and > accept that it might not be as performant. Hmm. Every time I try to think of a protocol change for the restore_command API that would be acceptable, I go around the same circle of thoughts about event flow and realise that what we really need for this is ... a WAL receiver... Here's a rebase over the recent commit "Get rid of the dedicated latch for signaling the startup process." just to fix cfbot; no other changes.
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix recovery_prefetch docs.
- dafae9707ab7 15.0 landed
-
Prefetch data referenced by the WAL, take II.
- 5dc0418fab28 15.0 landed
-
Add circular WAL decoding buffer, take II.
- 3f1ce973467a 15.0 landed
-
Fix generation of ./INSTALL for the distribution tarball
- 45aa88fe1d40 14.0 cited
-
Revert recovery prefetching feature.
- c2dc19342e05 14.0 landed
-
Sync guc.c and postgresql.conf.sample with the SGML docs.
- a55a98477b69 14.0 cited
-
Add information of total data processed to replication slot stats.
- f5fc2f5b23d1 14.0 cited
-
Doc: Review for "Optionally prefetch referenced data in recovery."
- dc88460c24ed 14.0 landed
-
Add circular WAL decoding buffer.
- f003d9f8721b 14.0 landed
-
Optionally prefetch referenced data in recovery.
- 1d257577e08d 14.0 landed
-
Remove read_page callback from XLogReader.
- 323cbe7c7ddc 14.0 cited
-
Provide ReadRecentBuffer() to re-pin buffers by ID.
- 2f27f8c51149 14.0 landed
-
Provide recovery_init_sync_method=syncfs.
- 61752afb2640 14.0 cited
-
Mark factorial operator, and postfix operators in general, as deprecated.
- 6ca547cf75ef 14.0 cited
-
Rationalize GetWalRcv{Write,Flush}RecPtr().
- d140f2f3e225 13.0 landed
-
Support PrefetchBuffer() in recovery.
- 3985b600f57d 13.0 landed
-
Prevent hard failures of standbys caused by recycled WAL segments
- 70b4f82a4b5c 11.0 cited