Skip to content

Commit bb93b33

Browse files
committed
Improve comment about dropped entries in pgstat.c
pgstat_write_statsfile() discards any entries marked as dropped from being written to the stats file at shutdown, and also included an assertion based on the same condition. The intention of the assertion is to track that no pgstats entries should be left around as terminating backends should drop any entries they still hold references on before the stats file is written by the checkpointer, and it not worth taking down the server in this case if there is a bug making that possible. Let's improve the comment of this area to document clearly what's intended. Based on a discussion with Bertrand Drouvot and Anton A. Melnikov. Author: Bertrand Drouvot Discussion: https://postgr.es/m/a13e8cdf-b97a-4ecb-8f42-aaa367974e29@postgrespro.ru Backpatch-through: 15
1 parent dc5f905 commit bb93b33

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/backend/utils/activity/pgstat.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,15 @@ pgstat_write_statsfile(void)
13961396

13971397
CHECK_FOR_INTERRUPTS();
13981398

1399-
/* we may have some "dropped" entries not yet removed, skip them */
1399+
/*
1400+
* We should not see any "dropped" entries when writing the stats
1401+
* file, as all backends and auxiliary processes should have cleaned
1402+
* up their references before they terminated.
1403+
*
1404+
* However, since we are already shutting down, it is not worth
1405+
* crashing the server over any potential cleanup issues, so we simply
1406+
* skip such entries if encountered.
1407+
*/
14001408
Assert(!ps->dropped);
14011409
if (ps->dropped)
14021410
continue;

0 commit comments

Comments
 (0)