Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) - Mailing list pgsql-hackers
From | Robert Haas |
---|---|
Subject | Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) |
Date | |
Msg-id | CA+TgmoYgCs=SEsohP6Z6R3KKsGaqFqvqxH8vQ_-nY4t+7rK8jg@mail.gmail.com Whole thread Raw |
In response to | Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) (Melanie Plageman <melanieplageman@gmail.com>) |
List | pgsql-hackers |
I find this patch set quite hard to follow. 0001 altogether removes the use of XLOG_HEAP2_VISIBLE in cases where we use XLOG_HEAP2_MULTI_INSERT, but then 0007 (the next non-refactoring patch) begins half-removing the dependency on XLOG_HEAP2_VISIBLE, assisted by 0009 and 0010, and then later you come back and remove the other half of the dependency. I know it was I who proposed (off-list) first making the XLOG_HEAP2_VISIBLE record only deal with the VM page and not the heap buffer, but I'm not sure that idea quite worked out in terms of making this easier to follow. At the least, it seems weird that COPY FREEZE is an exception that gets handled in a different way than all the other cases, fully removing the dependency in one step. It would also be nice if each time you repost this, or maybe in a README that you post along beside the actual patches, you'd include some kind of roadmap to help the reader understand the internal structure of the patch set, like 1 does this, 2-9 get us to here, 10-whatever get us to this next place. I don't really understand how the interlocking works. 0011 changes visibilitymap_set so that it doesn't take the heap block as an argument, but we'd better hold a lock on the heap page while setting the VM bit, otherwise I think somebody could come along and modify the heap page after we decided it was all-visible and before we actually set the VM bit, which would be terrible. I would expect the comments and the commit message to say something about that, but I don't see that they do. I find myself fearful of the way that 0007 propagates the existing hacks around setting the VM bit into a new place: + /* + * We always emit a WAL record when setting PD_ALL_VISIBLE, but we are + * careful not to emit a full page image unless + * checksums/wal_log_hints are enabled. We only set the heap page LSN + * if full page images were an option when emitting WAL. Otherwise, + * subsequent modifications of the page may incorrectly skip emitting + * a full page image. + */ + if (do_prune || nplans > 0 || + (xlrec.flags & XLHP_SET_PD_ALL_VIS && XLogHintBitIsNeeded())) + PageSetLSN(page, lsn); I suppose it's not the worst thing to duplicate this logic, because you're later going to remove the original copy. But, it took me >10 minutes to find the text in src/backend/access/transam/README, in the second half of the "Writing Hints" section, that explains the overall principle here, and since the patch set doesn't seem to touch that text, maybe you weren't even aware it was there. And, it's a little weird to have a single WAL record that is either a hint or not a hint depending on a complex set of conditions. (IMHO mixing & and && without parentheses is quite brave, and an explicit != 0 might not be a bad idea either.) Anyway, I kind of wonder if it's time to back out the hack that I installed here many years ago. At the time, I thought that it would be bad if a VACUUM swept over the visibility map setting VM bits and as a result emitted an FPI for every page in the entire heap ... but everyone who is running with checksums has accepted that cost already, and with those being the default, that's probably going to be most people. It would be even more compelling if we were going to freeze, prune, and set all-visible on access, because then presumably the case where we touch a page and ONLY set the VM bit would be rare, so the cost of doing that wouldn't matter much, but I guess the patch doesn't go that far -- we can freeze or set all-visible on access but not prune, without which the scenario I was worrying about at the time is still fairly plausible, I think, if checksums are turned off. -- Robert Haas EDB: http://www.enterprisedb.com
pgsql-hackers by date: