@@ -7671,7 +7671,8 @@ CheckPointReplicationState(int flags)
7671
7671
/*
7672
7672
* NEON: we use logical records to persist information of about slots, origins, relation map...
7673
7673
* If it is done inside shutdown checkpoint, then Postgres panics: "concurrent write-ahead log activity while database system is shutting down"
7674
- * So it before checkpoint REDO position is determined.
7674
+ * So do it before checkpoint REDO position is determined.
7675
+ * The same is true for CheckPointBuffers which wallog dirty FSM/VM pages.
7675
7676
*/
7676
7677
static void
7677
7678
PreCheckPointGuts (int flags )
@@ -7680,10 +7681,11 @@ PreCheckPointGuts(int flags)
7680
7681
{
7681
7682
CheckPointReplicationState (flags );
7682
7683
CheckPointBuffers (flags );
7684
+
7683
7685
/*
7684
7686
* pgstat_write_statsfile will be called later by before_shmem_exit() hook, but by then it's too late
7685
7687
* to write WAL records. In Neon, pgstat_write_statsfile() writes the pgstats file to the WAL, so we have
7686
- * to call it earlier. (The call that happens later is useless, but it doesn't do any harm either)
7688
+ * to call it earlier. (The call that happens later is useless, but it doesn't do any harm either)
7687
7689
*/
7688
7690
pgstat_write_statsfile ();
7689
7691
}
@@ -7709,6 +7711,12 @@ CheckPointGuts(XLogRecPtr checkPointRedo, int flags)
7709
7711
CheckPointSUBTRANS ();
7710
7712
CheckPointMultiXact ();
7711
7713
CheckPointPredicate ();
7714
+ /*
7715
+ * NEON: Checkpoint buffer will write dirty pages to the disk and Neon SMGR
7716
+ * wallog FSM/VM pages to persist them at page server.
7717
+ * Writing to the WAL during shutdown checkpoint cause Postgres panic.
7718
+ * So do it before in PreCheckPointGuts.
7719
+ */
7712
7720
if (!(flags & CHECKPOINT_IS_SHUTDOWN ))
7713
7721
CheckPointBuffers (flags );
7714
7722
0 commit comments