Skip to content

Commit d56e79c

Browse files
author
Konstantin Knizhnik
committedApr 5, 2025·
Add comment explaning why CheckPointBuffers has to be called in PreCheckPointGuts
1 parent 2e1f8ab commit d56e79c

File tree

1 file changed

+9
-1
lines changed
  • src/backend/access/transam

1 file changed

+9
-1
lines changed
 

Diff for: ‎src/backend/access/transam/xlog.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -7215,6 +7215,7 @@ CheckPointReplicationState(void)
72157215
* NEON: we use logical records to persist information of about slots, origins, relation map...
72167216
* If it is done inside shutdown checkpoint, then Postgres panics: "concurrent write-ahead log activity while database system is shutting down"
72177217
* So do it before checkpoint REDO position is determined.
7218+
* The same is true for CheckPointBuffers which wallog dirty FSM/VM pages.
72187219
*/
72197220
static void
72207221
PreCheckPointGuts(int flags)
@@ -7223,10 +7224,11 @@ PreCheckPointGuts(int flags)
72237224
{
72247225
CheckPointReplicationState();
72257226
CheckPointBuffers(flags);
7227+
72267228
/*
72277229
* pgstat_write_statsfile will be called later by before_shmem_exit() hook, but by then it's too late
72287230
* 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)
72307232
*/
72317233
pgstat_write_statsfile();
72327234
}
@@ -7252,6 +7254,12 @@ CheckPointGuts(XLogRecPtr checkPointRedo, int flags)
72527254
CheckPointSUBTRANS();
72537255
CheckPointMultiXact();
72547256
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+
*/
72557263
if (!(flags & CHECKPOINT_IS_SHUTDOWN))
72567264
CheckPointBuffers(flags);
72577265

0 commit comments

Comments
 (0)