Skip to content

Commit 734c057

Browse files
committed
Add assertion in pgstat_write_statsfile() about processes allowed
This routine can currently only be called from the postmaster in single-user mode or the checkpointer, but there was no sanity check to make sure that this was always the case. This has proved to be useful when hacking the zone (at least to me), to make sure that the write of the pgstats file happens at shutdown, as wanted by design, in the correct process context. Discussion: https://postgr.es/m/ZnEiqAITL-VgZDoY@paquier.xyz
1 parent 63909da commit 734c057

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/utils/activity/pgstat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,9 @@ pgstat_write_statsfile(void)
13601360

13611361
pgstat_assert_is_up();
13621362

1363+
/* should be called only by the checkpointer or single user mode */
1364+
Assert(!IsUnderPostmaster || MyBackendType == B_CHECKPOINTER);
1365+
13631366
/* we're shutting down, so it's ok to just override this */
13641367
pgstat_fetch_consistency = PGSTAT_FETCH_CONSISTENCY_NONE;
13651368

0 commit comments

Comments
 (0)