]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Cleanup comments/docs around the new shmem request callbacks
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 7 Jul 2026 19:32:36 +0000 (22:32 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 7 Jul 2026 19:35:40 +0000 (22:35 +0300)
Make it explicit in the docs that the shmem initialization callbacks
are called while holding ShmemIndexLock.

Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5sHs+eSiTDOd14buayc6JbBX=Hm5ssFMBK0Ki9sTGEOuA@mail.gmail.com
Backpatch-through: 19

doc/src/sgml/xfunc.sgml
src/backend/storage/ipc/shmem.c

index bae16d7fb53b6bb37a4937404efb1ed7b10e205b..cb3cc09f16db409176f912a10b52c1cf0c157ee6 100644 (file)
@@ -3739,8 +3739,8 @@ my_shmem_init(void *arg)
       startup, it will immediately call the appropriate callbacks, depending
       on whether the requested memory areas were already initialized by
       another backend. The callbacks will be called while holding an internal
-      lock, which prevents concurrent two backends from initializing the
-      memory area concurrently.
+      lock (ShmemIndexLock), which prevents the race condition of two backends
+      trying to initializing the memory area at the same time.
      </para>
     </sect3>
 
index f1f7cd3a4ff2cb3851d4bfe5b73ba9544303de53..1fbba9c3a4cd464104014ae2610d44abfaa2eb0b 100644 (file)
@@ -918,7 +918,10 @@ CallShmemCallbacksAfterStartup(const ShmemCallbacks *callbacks)
                return;
        }
 
-       /* Hold ShmemIndexLock while we allocate all the shmem entries */
+       /*
+        * Hold ShmemIndexLock while we allocate all the shmem entries and run all
+        * the initializers.
+        */
        LWLockAcquire(ShmemIndexLock, LW_EXCLUSIVE);
 
        /*
@@ -937,7 +940,7 @@ CallShmemCallbacksAfterStartup(const ShmemCallbacks *callbacks)
                        notfound_any = true;
        }
        if (found_any && notfound_any)
-               elog(ERROR, "found some but not all");
+               elog(ERROR, "some of the requested shmem areas have already been initialized");
 
        /*
         * Allocate or attach all the shmem areas requested by the request_fn