diff options
author | Jeff Davis <jdavis@postgresql.org> | 2022-11-12 08:37:50 -0800 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2022-11-12 08:37:50 -0800 |
commit | 97c61f70d1b97bdfd20dcb1f2b1be42862ec88c2 (patch) | |
tree | 06032b3378b5dcfe7e84a7e71d4b76c05ba0e23a /src/backend/access/heap/visibilitymap.c | |
parent | d6a3dbe14f98d867b2fc3faeb99d2d3c2a48ca67 (diff) | |
download | postgresql-97c61f70d1b97bdfd20dcb1f2b1be42862ec88c2.tar.gz postgresql-97c61f70d1b97bdfd20dcb1f2b1be42862ec88c2.zip |
Document WAL rules related to PD_ALL_VISIBLE in README.
Also improve comments.
Discussion: https://postgr.es/m/a50005c1c537f89bb359057fd70e66bb83bce969.camel@j-davis.com
Reviewed-by: Peter Geoghegan
Diffstat (limited to 'src/backend/access/heap/visibilitymap.c')
-rw-r--r-- | src/backend/access/heap/visibilitymap.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c index d62761728b0..4ed70275e22 100644 --- a/src/backend/access/heap/visibilitymap.c +++ b/src/backend/access/heap/visibilitymap.c @@ -223,13 +223,13 @@ visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf) * visibilitymap_set - set bit(s) on a previously pinned page * * recptr is the LSN of the XLOG record we're replaying, if we're in recovery, - * or InvalidXLogRecPtr in normal running. The page LSN is advanced to the + * or InvalidXLogRecPtr in normal running. The VM page LSN is advanced to the * one provided; in normal running, we generate a new XLOG record and set the - * page LSN to that value. cutoff_xid is the largest xmin on the page being - * marked all-visible; it is needed for Hot Standby, and can be - * InvalidTransactionId if the page contains no tuples. It can also be set - * to InvalidTransactionId when a page that is already all-visible is being - * marked all-frozen. + * page LSN to that value (though the heap page's LSN may *not* be updated; + * see below). cutoff_xid is the largest xmin on the page being marked + * all-visible; it is needed for Hot Standby, and can be InvalidTransactionId + * if the page contains no tuples. It can also be set to InvalidTransactionId + * when a page that is already all-visible is being marked all-frozen. * * Caller is expected to set the heap page's PD_ALL_VISIBLE bit before calling * this function. Except in recovery, caller should also pass the heap @@ -289,6 +289,11 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf, /* * If data checksums are enabled (or wal_log_hints=on), we * need to protect the heap page from being torn. + * + * If not, then we must *not* update the heap page's LSN. In + * this case, the FPI for the heap page was omitted from the + * WAL record inserted above, so it would be incorrect to + * update the heap page's LSN. */ if (XLogHintBitIsNeeded()) { |