Skip to content

Commit 66114c2

Browse files
author
Konstantin Knizhnik
committed
Add comment explaning why CheckPointBuffers has to be called in PreCheckPointGuts
1 parent 76b81ee commit 66114c2

File tree

1 file changed

+10
-2
lines changed
  • src/backend/access/transam

1 file changed

+10
-2
lines changed

src/backend/access/transam/xlog.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -7671,7 +7671,8 @@ CheckPointReplicationState(int flags)
76717671
/*
76727672
* NEON: we use logical records to persist information of about slots, origins, relation map...
76737673
* 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.
76757676
*/
76767677
static void
76777678
PreCheckPointGuts(int flags)
@@ -7680,10 +7681,11 @@ PreCheckPointGuts(int flags)
76807681
{
76817682
CheckPointReplicationState(flags);
76827683
CheckPointBuffers(flags);
7684+
76837685
/*
76847686
* pgstat_write_statsfile will be called later by before_shmem_exit() hook, but by then it's too late
76857687
* 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)
76877689
*/
76887690
pgstat_write_statsfile();
76897691
}
@@ -7709,6 +7711,12 @@ CheckPointGuts(XLogRecPtr checkPointRedo, int flags)
77097711
CheckPointSUBTRANS();
77107712
CheckPointMultiXact();
77117713
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+
*/
77127720
if (!(flags & CHECKPOINT_IS_SHUTDOWN))
77137721
CheckPointBuffers(flags);
77147722

0 commit comments

Comments
 (0)