Re: Warn when parallel restoring a custom dump without data offsets
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Gilman <dgilman@gilslotd.com>
Cc: pgsql-hackers@lists.postgresql.org, pryzby@telsasoft.com
Date: 2020-07-12T19:57:58Z
Lists: pgsql-hackers
Attachments
- 0001-remember-seek-positions.patch (text/x-diff) patch 0001
- 0002-Add-integration-test-for-out-of-order-TOC-requests-i.patch (text/x-diff) patch 0002
David Gilman <dgilman@gilslotd.com> writes: > On Thu, Jul 02, 2020 at 05:25:21PM -0400, Tom Lane wrote: >> I guess I'm completely confused about the purpose of these patches. >> Far from coping with the situation of an unseekable file, they appear >> to change pg_restore so that it fails altogether if it can't seek >> its input file. Why would we want to do this? > I'm not sure where the "fails altogether if it can't seek" is. I misread the patch, is where :-( As penance, I spent some time studying this patchset, and have a few comments: 1. The proposed doc change in 0001 seems out-of-date; isn't it adding a warning about exactly the deficiency that the rest of the patch is eliminating? Note that the preceding para already says that the input has to be seekable, so that's covered. Maybe there is reason for documenting that parallel restore will be slower if the archive was written in a non-seekable way ... but that's not what this says. 2. It struck me that the patch is still pretty inefficient, in that anytime it has to back up in an offset-less archive, it blindly rewinds to dataStart and rescans everything. In the worst case that'd still be O(N^2) work, and it's really not necessary, because once we've seen a given data block we know where it is. We just have to remember that, which seems easy enough. (Well, on Windows it's a bit trickier because the state in question is shared across threads; but that's good, it might save some work.) 3. Extending on #2, we actually don't need the rewind and retry logic at all. If we are looking for a block we haven't already seen, and we get to the end of the archive, it ain't there. (This is a bit less obvious in the Windows case than otherwise, but I think it's still true, given that the start state is either "all offsets known" or "no offsets known". A particular thread might skip over some blocks on the strength of an offset established by another thread, but the blocks ahead of that spot must now all have known offsets.) 4. Patch 0002 seems mighty expensive for the amount of code coverage it's adding. On my machine it seems to raise the overall runtime of pg_dump's "make installcheck" by about 10%, and the only new coverage is of the few lines added here. I wonder if we couldn't cover that more cheaply by testing what happens when we use a "-L" option with an intentionally mis-sorted restore list. 5. I'm inclined to reject 0003. It's not saving anything very meaningful, and we'd just have to put the code back whenever somebody gets around to making pg_backup_tar.c capable of out-of-order restores like pg_backup_custom.c is now able to do. The attached 0001 rewrites your 0001 as per the above ideas (dropping the proposed doc change for now), and includes your 0004 for simplicity. I'm including your 0002 verbatim just so the cfbot will be able to do a meaningful test on 0001; but as stated, I don't really want to commit it. regards, tom lane
Commits
-
Cope with data-offset-less archive files during out-of-order restores.
- 71e8e66f783c 13.0 landed
- f009591d6edd 14.0 landed
- 66232220ee6e 12.4 landed
-
Remove manual tracking of file position in pg_dump/pg_backup_custom.c.
- 447cf2f8e9dc 13.0 landed
- a8d0732ac2b5 14.0 landed
- 39a068ce6675 12.4 landed
-
Improve performance of tuple conversion map generation
- 42f70cd9c3db 12.0 cited
-
Fix pg_restore so parallel restore doesn't fail when the input file doesn't
- b779ea8a9a2d 9.0.0 cited