diff options
author | Noah Misch <noah@leadboat.com> | 2020-03-21 09:38:33 -0700 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2020-03-21 09:38:33 -0700 |
commit | ae86e46c3b7b90903d89b65385e2b77d2c1cf63e (patch) | |
tree | 78857d63bad6c56c73cbf5488b28365b46e5fb43 /src/backend/access/transam/xlog.c | |
parent | 4433c6e8c0a5d0891c9bb52d14e73464086c0375 (diff) | |
download | postgresql-ae86e46c3b7b90903d89b65385e2b77d2c1cf63e.tar.gz postgresql-ae86e46c3b7b90903d89b65385e2b77d2c1cf63e.zip |
Back-patch log_newpage_range().
Back-patch a subset of commit 9155580fd5fc2a0cbb23376dfca7cd21f59c2c7b
to v11, v10, 9.6, and 9.5. Include the latest repairs to this function.
Use a new XLOG_FPI_MULTI value instead of reusing XLOG_FPI. That way,
if an older server reads WAL from this function, that server will PANIC
instead of applying just one page of the record. The next commit adds a
call to this function.
Discussion: https://postgr.es/m/20200304.162919.898938381201316571.horikyota.ntt@gmail.com
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 40eb77425e8..62f87ed1741 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9754,7 +9754,7 @@ xlog_redo(XLogReaderState *record) /* in XLOG rmgr, backup blocks are only used by XLOG_FPI records */ Assert(info == XLOG_FPI || info == XLOG_FPI_FOR_HINT || - !XLogRecHasAnyBlockRefs(record)); + info == XLOG_FPI_MULTI || !XLogRecHasAnyBlockRefs(record)); if (info == XLOG_NEXTOID) { @@ -9957,14 +9957,16 @@ xlog_redo(XLogReaderState *record) { /* nothing to do here */ } - else if (info == XLOG_FPI || info == XLOG_FPI_FOR_HINT) + else if (info == XLOG_FPI || info == XLOG_FPI_FOR_HINT || + info == XLOG_FPI_MULTI) { - Buffer buffer; + uint8 block_id; /* * Full-page image (FPI) records contain nothing else but a backup - * block. The block reference must include a full-page image - - * otherwise there would be no point in this record. + * block (or multiple backup blocks). Every block reference must + * include a full-page image - otherwise there would be no point in + * this record. * * No recovery conflicts are generated by these generic records - if a * resource manager needs to generate conflicts, it has to define a @@ -9976,9 +9978,14 @@ xlog_redo(XLogReaderState *record) * XLOG_FPI and XLOG_FPI_FOR_HINT records, they use a different info * code just to distinguish them for statistics purposes. */ - if (XLogReadBufferForRedo(record, 0, &buffer) != BLK_RESTORED) - elog(ERROR, "unexpected XLogReadBufferForRedo result when restoring backup block"); - UnlockReleaseBuffer(buffer); + for (block_id = 0; block_id <= record->max_block_id; block_id++) + { + Buffer buffer; + + if (XLogReadBufferForRedo(record, block_id, &buffer) != BLK_RESTORED) + elog(ERROR, "unexpected XLogReadBufferForRedo result when restoring backup block"); + UnlockReleaseBuffer(buffer); + } } else if (info == XLOG_BACKUP_END) { |