diff options
author | Nathan Bossart <nathan@postgresql.org> | 2024-01-19 14:24:36 -0600 |
---|---|---|
committer | Nathan Bossart <nathan@postgresql.org> | 2024-01-19 14:24:36 -0600 |
commit | 8b2bcf3f287c79eaebf724cba57e5ff664b01e06 (patch) | |
tree | 60a986a9824dced9cca2a5b53b93bfe7ea59216a /src/backend/utils | |
parent | 964152c476f25ada4c5832a014999ec2d2980358 (diff) | |
download | postgresql-8b2bcf3f287c79eaebf724cba57e5ff664b01e06.tar.gz postgresql-8b2bcf3f287c79eaebf724cba57e5ff664b01e06.zip |
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
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/activity/wait_event_names.txt | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt index f625473ad43..6bcb1cca0cb 100644 --- a/src/backend/utils/activity/wait_event_names.txt +++ b/src/backend/utils/activity/wait_event_names.txt @@ -329,6 +329,7 @@ WrapLimitsVacuum "Waiting to update limits on transaction id and multixact consu NotifyQueueTail "Waiting to update limit on <command>NOTIFY</command> message storage." WaitEventExtension "Waiting to read or update custom wait events information for extensions." WALSummarizer "Waiting to read or update WAL summarization state." +DSMRegistry "Waiting to read or update the dynamic shared memory registry." # # END OF PREDEFINED LWLOCKS (DO NOT CHANGE THIS LINE) @@ -367,6 +368,8 @@ PgStatsHash "Waiting for stats shared memory hash table access." PgStatsData "Waiting for shared memory stats data access." LogicalRepLauncherDSA "Waiting to access logical replication launcher's dynamic shared memory allocator." LogicalRepLauncherHash "Waiting to access logical replication launcher's shared hash table." +DSMRegistryDSA "Waiting to access dynamic shared memory registry's dynamic shared memory allocator." +DSMRegistryHash "Waiting to access dynamic shared memory registry's shared hash table." # # Wait Events - Lock |