aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-12-09 14:35:46 +0900
committerMichael Paquier <michael@paquier.xyz>2024-12-09 14:35:46 +0900
commitec194b448cbc7f9fe2204cdb7690eb4c21a46d8e (patch)
tree7edff574e4ca51a6b7d6ef4cf267018486892d73 /src
parentae77bcc3aa1b869568c6b01726e4f1276f7381bb (diff)
downloadpostgresql-ec194b448cbc7f9fe2204cdb7690eb4c21a46d8e.tar.gz
postgresql-ec194b448cbc7f9fe2204cdb7690eb4c21a46d8e.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/activity/pgstat.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c
index 1c0b1625e30..26da09d73ab 100644
--- a/src/backend/utils/activity/pgstat.c
+++ b/src/backend/utils/activity/pgstat.c
@@ -1399,7 +1399,15 @@ pgstat_write_statsfile(void)
CHECK_FOR_INTERRUPTS();
- /* we may have some "dropped" entries not yet removed, skip them */
+ /*
+ * We should not see any "dropped" entries when writing the stats
+ * file, as all backends and auxiliary processes should have cleaned
+ * up their references before they terminated.
+ *
+ * However, since we are already shutting down, it is not worth
+ * crashing the server over any potential cleanup issues, so we simply
+ * skip such entries if encountered.
+ */
Assert(!ps->dropped);
if (ps->dropped)
continue;