Re: WIP: WAL prefetch (another approach)
Thomas Munro <thomas.munro@gmail.com>
Attachments
- v7-0001-Rationalize-GetWalRcv-Write-Flush-RecPtr.patch (text/x-patch) patch v7-0001
- v7-0002-Add-pg_atomic_unlocked_add_fetch_XXX.patch (text/x-patch) patch v7-0002
- v7-0003-Allow-XLogReadRecord-to-be-non-blocking.patch (text/x-patch) patch v7-0003
- v7-0004-Prefetch-referenced-blocks-during-recovery.patch (text/x-patch) patch v7-0004
On Wed, Apr 8, 2020 at 12:52 PM Thomas Munro <thomas.munro@gmail.com> wrote: > * he gave some feedback on the read_local_xlog_page() modifications: I > probably need to reconsider the change to logical.c that passes NULL > instead of cxt to the read_page callback; and the switch statement in > read_local_xlog_page() probably should have a case for the preexisting > mode So... logical.c wants to give its LogicalDecodingContext to any XLogPageReadCB you give it, via "private_data"; that is, it really only accepts XLogPageReadCB implementations that understand that (or ignore it). What I want to do is give every XLogPageReadCB the chance to have its own state that it is control of (to receive settings specific to the implementation, or whatever), that you supply along with it. We can't do both kinds of things with private_data, so I have added a second member read_page_data to XLogReaderState. If you pass in read_local_xlog_page as read_page, then you can optionally install a pointer to XLogReadLocalOptions as reader->read_page_data, to activate the new behaviours I added for prefetching purposes. While working on that, I realised the readahead XLogReader was breaking a rule expressed in XLogReadDetermineTimeLine(). Timelines are really confusing and there were probably several subtle or not to subtle bugs there. So I added an option to skip all of that logic, and just say "I command you to read only from TLI X". It reads the same TLI as recovery is reading, until it hits the end of readable data and that causes prefetching to shut down. Then the main recovery loop resets the prefetching module when it sees a TLI switch, so then it starts up again. This seems to work reliably, but I've obviously had limited time to test. Does this scheme sound sane? I think this is basically committable (though of course I wish I had more time to test and review). Ugh. Feature freeze in half an hour.
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