Print lwlock stats also for aux processes, when built with LWLOCK_STATS
authorHeikki Linnakangas <[email protected]>
Thu, 30 Nov 2023 23:00:03 +0000 (01:00 +0200)
committerHeikki Linnakangas <[email protected]>
Thu, 30 Nov 2023 23:00:03 +0000 (01:00 +0200)
InitAuxiliaryProcess() closely resembles InitProcess(), but it didn't
call InitLWLockAccess(). But because InitLWLockAccess() is a no-op
unless compiled with LWLOCK_STATS, and everything works even if it's
not called, the only consequence was that the stats were not printed
for aux processes.

This was an oversight in commit 1c6821be31f, in version 9.5, so it is
missing in all supported branches. But since it only affects
developers using LWLOCK_STATS and no one has complained, no
backpatching.

Discussion: https://www.postgresql.org/message-id/20231130202648[email protected]

src/backend/storage/lmgr/proc.c

index e9e445bb2166d33a69e63aaa921a4d32bdaa8e8d..01f7019b10c7af1906e0d410c8569d42816e7dd0 100644 (file)
@@ -614,6 +614,13 @@ InitAuxiliaryProcess(void)
     * Arrange to clean up at process exit.
     */
    on_shmem_exit(AuxiliaryProcKill, Int32GetDatum(proctype));
+
+   /*
+    * Now that we have a PGPROC, we could try to acquire lightweight locks.
+    * Initialize local state needed for them.  (Heavyweight locks cannot be
+    * acquired in aux processes.)
+    */
+   InitLWLockAccess();
 }
 
 /*