pgstat: Schedule per-backend pgstat shutdown via before_shmem_exit().
authorAndres Freund
Fri, 6 Aug 2021 17:05:57 +0000 (10:05 -0700)
committerAndres Freund
Sat, 7 Aug 2021 02:11:05 +0000 (19:11 -0700)
Previously on_shmem_exit() was used. The upcoming shared memory stats patch
uses DSM segments to store stats, which can not be used after the
dsm_backend_shutdown() call in shmem_exit().

The preceding commits were required to permit this change. This commit is
split off the shared memory stats patch to make it easier to isolate problems
caused by the ordering changes rather than the much larger changes in where
stats are stored.

Author: Andres Freund 
Author: Kyotaro Horiguchi 
Discussion: https://postgr.es/m/20210405092914[email protected]
Discussion: https://postgr.es/m/20210802164124[email protected]
Discussion: https://postgr.es/m/20210803023612[email protected]

src/backend/postmaster/pgstat.c

index 9664e7f256f0e5f01e5de4e23e956f5e64d2af65..1b54ef74eb29f3480e8c01e0609b52ad096cadde 100644 (file)
@@ -2992,7 +2992,7 @@ pgstat_initialize(void)
    prevWalUsage = pgWalUsage;
 
    /* Set up a process-exit hook to clean up */
-   on_shmem_exit(pgstat_shutdown_hook, 0);
+   before_shmem_exit(pgstat_shutdown_hook, 0);
 
 #ifdef USE_ASSERT_CHECKING
    pgstat_is_initialized = true;