@@ -7215,6 +7215,7 @@ CheckPointReplicationState(void)
7215
7215
* NEON: we use logical records to persist information of about slots, origins, relation map...
7216
7216
* If it is done inside shutdown checkpoint, then Postgres panics: "concurrent write-ahead log activity while database system is shutting down"
7217
7217
* So do it before checkpoint REDO position is determined.
7218
+ * The same is true for CheckPointBuffers which wallog dirty FSM/VM pages.
7218
7219
*/
7219
7220
static void
7220
7221
PreCheckPointGuts (int flags )
@@ -7223,10 +7224,11 @@ PreCheckPointGuts(int flags)
7223
7224
{
7224
7225
CheckPointReplicationState ();
7225
7226
CheckPointBuffers (flags );
7227
+
7226
7228
/*
7227
7229
* pgstat_write_statsfile will be called later by before_shmem_exit() hook, but by then it's too late
7228
7230
* to write WAL records. In Neon, pgstat_write_statsfile() writes the pgstats file to the WAL, so we have
7229
- * to call it earlier. (The call that happens later is useless, but it doesn't do any harm either)
7231
+ * to call it earlier. (The call that happens later is useless, but it doesn't do any harm either)
7230
7232
*/
7231
7233
pgstat_write_statsfile ();
7232
7234
}
@@ -7252,6 +7254,12 @@ CheckPointGuts(XLogRecPtr checkPointRedo, int flags)
7252
7254
CheckPointSUBTRANS ();
7253
7255
CheckPointMultiXact ();
7254
7256
CheckPointPredicate ();
7257
+ /*
7258
+ * NEON: Checkpoint buffer will write dirty pages to the disk and Neon SMGR
7259
+ * wallog FSM/VM pages to persist them at page server.
7260
+ * Writing to the WAL during shutdown checkpoint cause Postgres panic.
7261
+ * So do it before in PreCheckPointGuts.
7262
+ */
7255
7263
if (!(flags & CHECKPOINT_IS_SHUTDOWN ))
7256
7264
CheckPointBuffers (flags );
7257
7265
0 commit comments