Fix bufmgr so CHECKPOINT_END_OF_RECOVERY behaves as a shutdown checkpoint.
authorSimon Riggs
Sun, 16 Sep 2012 18:54:34 +0000 (19:54 +0100)
committerSimon Riggs
Sun, 16 Sep 2012 18:54:34 +0000 (19:54 +0100)
Recovery code documents clearly that a shutdown checkpoint is executed at
end of recovery - a shutdown checkpoint WAL record is written but the buffer
manager had been altered to treat end of recovery as a normal checkpoint.
This bug exacerbates the bufmgr relpersistence bug.

Bug spotted by Andres Freund, patch by me.

src/backend/storage/buffer/bufmgr.c

index f1c29e9d4a89b31e1994d8d52e6e6c53daf11226..77d4fbf0b9ae40d885ee513abfb3999ce69ea8df 100644 (file)
@@ -1206,9 +1206,9 @@ BufferSync(int flags)
 
    /*
     * Unless this is a shutdown checkpoint, we write only permanent, dirty
-    * buffers.  But at shutdown time, we write all dirty buffers.
+    * buffers.  But at shutdown or end of recovery, we write all dirty buffers.
     */
-   if (!(flags & CHECKPOINT_IS_SHUTDOWN))
+   if (!((flags & CHECKPOINT_IS_SHUTDOWN) || (flags & CHECKPOINT_END_OF_RECOVERY)))
        mask |= BM_PERMANENT;
 
    /*