postgresql/src/include/storage
Nathan Bossart 8b2bcf3f28 Introduce the dynamic shared memory registry.
Presently, the most straightforward way for a shared library to use
shared memory is to request it at server startup via a
shmem_request_hook, which requires specifying the library in
shared_preload_libraries.  Alternatively, the library can create a
dynamic shared memory (DSM) segment, but absent a shared location
to store the segment's handle, other backends cannot use it.  This
commit introduces a registry for DSM segments so that these other
backends can look up existing segments with a library-specified
string.  This allows libraries to easily use shared memory without
needing to request it at server startup.

The registry is accessed via the new GetNamedDSMSegment() function.
This function handles allocating the segment and initializing it
via a provided callback.  If another backend already created and
initialized the segment, it simply attaches the segment.
GetNamedDSMSegment() locks the registry appropriately to ensure
that only one backend initializes the segment and that all other
backends just attach it.

The registry itself is comprised of a dshash table that stores the
DSM segment handles keyed by a library-specified string.

Reviewed-by: Michael Paquier, Andrei Lepikhov, Nikita Malakhov, Robert Haas, Bharath Rupireddy, Zhang Mingli, Amul Sul
Discussion: https://postgr.es/m/20231205034647.GA2705267%40nathanxps13
2024-01-19 14:24:36 -06:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
barrier.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
block.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
buf.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
buf_internals.h Add missing PGDLLIMPORT markings 2024-01-16 13:53:28 +02:00
buffile.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
bufmgr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
bufpage.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
checksum.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
checksum_impl.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
condition_variable.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
copydir.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
dsm.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
dsm_impl.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
dsm_registry.h Introduce the dynamic shared memory registry. 2024-01-19 14:24:36 -06:00
fd.h Refactor code checking for file existence 2024-01-12 12:04:51 +09:00
fileset.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
freespace.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
fsm_internals.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
indexfsm.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
ipc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
item.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
itemid.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
itemptr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
large_object.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
latch.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
lmgr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
lock.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
lockdefs.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
lwlock.h Introduce the dynamic shared memory registry. 2024-01-19 14:24:36 -06:00
md.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
meson.build Cross-check lists of predefined LWLocks. 2024-01-09 11:05:19 -06:00
off.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_sema.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_shmem.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pmsignal.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
predicate.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
predicate_internals.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
proc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
procarray.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
proclist.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
proclist_types.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
procsignal.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
reinit.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
relfilelocator.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
s_lock.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
sharedfileset.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
shm_mq.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
shm_toc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
shmem.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
sinval.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
sinvaladt.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
smgr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
spin.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
standby.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
standbydefs.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
sync.h Update copyright for 2024 2024-01-03 20:49:05 -05:00