]> granicus.if.org Git - postgresql/commitdiff
Don't attempt to verify checksums on new pages
authorMagnus Hagander <magnus@hagander.net>
Sun, 15 Apr 2018 12:05:56 +0000 (14:05 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sun, 15 Apr 2018 12:05:56 +0000 (14:05 +0200)
Teach both base backups and pg_verify_checksums that if a page is new,
it does not have a checksum yet, so it shouldn't be verified.

Noted by Tomas Vondra, review by David Steele.

src/backend/replication/basebackup.c
src/bin/pg_verify_checksums/pg_verify_checksums.c

index 50c052e993598a07f55675e5e9046a8d3b6af86d..a79048d233d54d0384e8d645a5d33cde942e8996 100644 (file)
@@ -1446,8 +1446,10 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
                                 * written only halfway and the checksum would not be valid.
                                 * However, replaying WAL would reinstate the correct page in
                                 * this case.
+                                * We also skip completely new pages, since they don't have
+                                * a checksum yet.
                                 */
-                               if (PageGetLSN(page) < startptr)
+                               if (!PageIsNew(page) && PageGetLSN(page) < startptr)
                                {
                                        checksum = pg_checksum_page((char *) page, blkno + segmentno * RELSEG_SIZE);
                                        phdr = (PageHeader) page;
index d472f1291c56d9035368d76b179d6672b7133450..b065d0bb89728d732135483590f9160f7275829a 100644 (file)
@@ -106,6 +106,10 @@ scan_file(char *fn, int segmentno)
                }
                blocks++;
 
+               /* New pages have no checksum yet */
+               if (PageIsNew(buf))
+                       continue;
+
                csum = pg_checksum_page(buf, blockno + segmentno * RELSEG_SIZE);
                if (csum != header->pd_checksum)
                {