=== Applying patches on top of PostgreSQL commit ID 81b2179b492e3af891544813b7e22a42386b34d0 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sat Nov 14 22:30:33 UTC 2026 On branch cf/6652 nothing to commit, working tree clean === using 'git am' to apply patch ./v20260813-0001-Resizable-shared-memory-structures.patch === Applying: Resizable shared memory structures Using index info to reconstruct a base tree... M configure.ac M doc/src/sgml/config.sgml M doc/src/sgml/runtime.sgml M doc/src/sgml/system-views.sgml M doc/src/sgml/xfunc.sgml M meson.build M src/backend/storage/ipc/shmem.c M src/backend/storage/lmgr/proc.c M src/backend/utils/init/postinit.c M src/backend/utils/misc/guc_parameters.dat M src/backend/utils/misc/guc_tables.c M src/include/catalog/pg_proc.dat M src/include/pg_config.h.in M src/test/modules/test_shmem/meson.build M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl M src/test/modules/test_shmem/test_shmem--1.0.sql M src/test/modules/test_shmem/test_shmem.c M src/test/regress/expected/rules.out M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list CONFLICT (content): Merge conflict in src/tools/pgindent/typedefs.list Auto-merging src/test/regress/expected/rules.out Auto-merging src/test/modules/test_shmem/test_shmem.c CONFLICT (content): Merge conflict in src/test/modules/test_shmem/test_shmem.c Auto-merging src/test/modules/test_shmem/test_shmem--1.0.sql CONFLICT (content): Merge conflict in src/test/modules/test_shmem/test_shmem--1.0.sql Auto-merging src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl CONFLICT (content): Merge conflict in src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl Auto-merging src/test/modules/test_shmem/meson.build Auto-merging src/include/pg_config.h.in Auto-merging src/include/catalog/pg_proc.dat Auto-merging src/backend/utils/misc/guc_tables.c Auto-merging src/backend/utils/misc/guc_parameters.dat Auto-merging src/backend/utils/init/postinit.c Auto-merging src/backend/storage/lmgr/proc.c Auto-merging src/backend/storage/ipc/shmem.c CONFLICT (content): Merge conflict in src/backend/storage/ipc/shmem.c Auto-merging meson.build Auto-merging doc/src/sgml/xfunc.sgml Auto-merging doc/src/sgml/system-views.sgml Auto-merging doc/src/sgml/runtime.sgml Auto-merging doc/src/sgml/config.sgml Auto-merging configure.ac error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Resizable shared memory structures When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v20260813-0001-Resizable-shared-memory-structures.patch === patching file configure.ac Hunk #1 succeeded at 1927 (offset 15 lines). patching file doc/src/sgml/config.sgml Hunk #1 succeeded at 12483 (offset 110 lines). Hunk #2 succeeded at 12676 (offset 110 lines). patching file doc/src/sgml/ref/postgres-ref.sgml patching file doc/src/sgml/runtime.sgml Hunk #1 succeeded at 1452 (offset 2 lines). Hunk #2 succeeded at 1468 (offset 2 lines). patching file doc/src/sgml/system-views.sgml patching file doc/src/sgml/xfunc.sgml Hunk #1 succeeded at 3757 (offset 13 lines). patching file meson.build Hunk #1 succeeded at 2903 (offset 9 lines). patching file src/backend/port/sysv_shmem.c patching file src/backend/port/win32_shmem.c patching file src/backend/postmaster/auxprocess.c patching file src/backend/storage/ipc/ipci.c patching file src/backend/storage/ipc/shmem.c Hunk #3 FAILED at 285. Hunk #4 succeeded at 303 with fuzz 1 (offset 10 lines). Hunk #5 FAILED at 360. Hunk #6 succeeded at 408 (offset 8 lines). Hunk #7 succeeded at 492 (offset 8 lines). Hunk #8 succeeded at 598 with fuzz 1 (offset 14 lines). Hunk #9 succeeded at 619 (offset 17 lines). Hunk #10 succeeded at 640 with fuzz 2 (offset 17 lines). Hunk #11 succeeded at 736 with fuzz 2 (offset 39 lines). Hunk #12 succeeded at 746 (offset 39 lines). Hunk #13 succeeded at 806 (offset 41 lines). Hunk #14 succeeded at 1197 with fuzz 2 (offset 41 lines). Hunk #15 succeeded at 1576 (offset 101 lines). Hunk #16 succeeded at 1598 (offset 101 lines). Hunk #17 succeeded at 1622 (offset 101 lines). Hunk #18 succeeded at 1633 (offset 101 lines). Hunk #19 FAILED at 1721. 3 out of 19 hunks FAILED -- saving rejects to file src/backend/storage/ipc/shmem.c.rej patching file src/backend/storage/lmgr/proc.c Hunk #1 succeeded at 574 (offset -1 lines). Hunk #2 succeeded at 763 (offset -1 lines). patching file src/backend/utils/init/postinit.c Hunk #1 succeeded at 788 (offset 1 line). patching file src/backend/utils/misc/guc_parameters.dat Hunk #1 succeeded at 1227 (offset 1 line). Hunk #2 succeeded at 2742 (offset 13 lines). patching file src/backend/utils/misc/guc_tables.c Hunk #1 succeeded at 652 (offset 9 lines). Hunk #2 succeeded at 677 (offset 9 lines). patching file src/include/catalog/pg_proc.dat Hunk #1 succeeded at 8751 (offset 59 lines). patching file src/include/pg_config.h.in patching file src/include/pg_config_manual.h patching file src/include/storage/ipc.h patching file src/include/storage/pg_shmem.h patching file src/include/storage/shmem.h patching file src/include/storage/shmem_internal.h patching file src/test/modules/test_shmem/meson.build Hunk #1 succeeded at 30 with fuzz 2 (offset 3 lines). patching file src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl (renamed from src/test/modules/test_shmem/t/001_late_shmem_alloc.pl) Hunk #1 FAILED at 56. 1 out of 1 hunk FAILED -- saving rejects to file src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl.rej patching file src/test/modules/test_shmem/t/002_resizable_shmem_struct.pl patching file src/test/modules/test_shmem/test_shmem--1.0.sql Hunk #1 FAILED at 4. 1 out of 1 hunk FAILED -- saving rejects to file src/test/modules/test_shmem/test_shmem--1.0.sql.rej patching file src/test/modules/test_shmem/test_shmem.c Hunk #2 FAILED at 16. Hunk #3 succeeded at 42 with fuzz 2 (offset 8 lines). Hunk #4 FAILED at 48. Hunk #5 FAILED at 70. Hunk #6 succeeded at 172 with fuzz 2 (offset 85 lines). 3 out of 6 hunks FAILED -- saving rejects to file src/test/modules/test_shmem/test_shmem.c.rej patching file src/test/regress/expected/rules.out patching file src/tools/pgindent/typedefs.list Hunk #1 FAILED at 3186. 1 out of 1 hunk FAILED -- saving rejects to file src/tools/pgindent/typedefs.list.rej Unstaged changes after reset: M configure.ac M doc/src/sgml/config.sgml M doc/src/sgml/ref/postgres-ref.sgml M doc/src/sgml/runtime.sgml M doc/src/sgml/system-views.sgml M doc/src/sgml/xfunc.sgml M meson.build M src/backend/port/sysv_shmem.c M src/backend/port/win32_shmem.c M src/backend/postmaster/auxprocess.c M src/backend/storage/ipc/ipci.c M src/backend/storage/ipc/shmem.c M src/backend/storage/lmgr/proc.c M src/backend/utils/init/postinit.c M src/backend/utils/misc/guc_parameters.dat M src/backend/utils/misc/guc_tables.c M src/include/catalog/pg_proc.dat M src/include/pg_config.h.in M src/include/pg_config_manual.h M src/include/storage/ipc.h M src/include/storage/pg_shmem.h M src/include/storage/shmem.h M src/include/storage/shmem_internal.h M src/test/modules/test_shmem/meson.build D src/test/modules/test_shmem/t/001_late_shmem_alloc.pl M src/test/modules/test_shmem/test_shmem.c M src/test/regress/expected/rules.out Removing src/backend/storage/ipc/shmem.c.rej Removing src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl Removing src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl.rej Removing src/test/modules/test_shmem/t/002_resizable_shmem_struct.pl Removing src/test/modules/test_shmem/test_shmem--1.0.sql.rej Removing src/test/modules/test_shmem/test_shmem.c.rej Removing src/tools/pgindent/typedefs.list.rej === using 'git apply' to apply patch ./v20260813-0001-Resizable-shared-memory-structures.patch === Applied patch to 'configure.ac' cleanly. Applied patch to 'doc/src/sgml/config.sgml' cleanly. Applied patch to 'doc/src/sgml/ref/postgres-ref.sgml' cleanly. Applied patch to 'doc/src/sgml/runtime.sgml' cleanly. Applied patch to 'doc/src/sgml/system-views.sgml' cleanly. Applied patch to 'doc/src/sgml/xfunc.sgml' cleanly. Applied patch to 'meson.build' cleanly. Applied patch to 'src/backend/port/sysv_shmem.c' cleanly. Applied patch to 'src/backend/port/win32_shmem.c' cleanly. Applied patch to 'src/backend/postmaster/auxprocess.c' cleanly. Applied patch to 'src/backend/storage/ipc/ipci.c' cleanly. Applied patch to 'src/backend/storage/ipc/shmem.c' with conflicts. Applied patch to 'src/backend/storage/lmgr/proc.c' cleanly. Applied patch to 'src/backend/utils/init/postinit.c' cleanly. Applied patch to 'src/backend/utils/misc/guc_parameters.dat' cleanly. Applied patch to 'src/backend/utils/misc/guc_tables.c' cleanly. Applied patch to 'src/include/catalog/pg_proc.dat' cleanly. Applied patch to 'src/include/pg_config.h.in' cleanly. Applied patch to 'src/include/pg_config_manual.h' cleanly. Applied patch to 'src/include/storage/ipc.h' cleanly. Applied patch to 'src/include/storage/pg_shmem.h' cleanly. Applied patch to 'src/include/storage/shmem.h' cleanly. Applied patch to 'src/include/storage/shmem_internal.h' cleanly. Applied patch to 'src/test/modules/test_shmem/meson.build' cleanly. Applied patch to 'src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl' with conflicts. Falling back to direct application... Applied patch to 'src/test/modules/test_shmem/test_shmem--1.0.sql' with conflicts. Applied patch to 'src/test/modules/test_shmem/test_shmem.c' with conflicts. Applied patch to 'src/test/regress/expected/rules.out' cleanly. Applied patch to 'src/tools/pgindent/typedefs.list' with conflicts. U src/backend/storage/ipc/shmem.c U src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl U src/test/modules/test_shmem/test_shmem--1.0.sql U src/test/modules/test_shmem/test_shmem.c U src/tools/pgindent/typedefs.list diff --cc src/backend/storage/ipc/shmem.c index 8d81893b470,fbc05f0dc13..00000000000 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@@ -276,16 -285,20 +293,25 @@@ typedef struct ShmemIndexEn void *location; /* location in shared mem */ Size size; /* # bytes requested for the structure */ Size allocated_size; /* # bytes actually allocated */ ++<<<<<<< ours + bool initialized; /* has the init callback been run? */ ++======= + Size minimum_size; /* the minimum size the structure can shrink + * to */ + Size maximum_size; /* the maximum size the structure can grow to */ + Size reserved_space; /* the total address space reserved */ ++>>>>>>> theirs } ShmemIndexEnt; /* To get reliable results for NUMA inquiry we need to "touch pages" once */ static bool firstNumaTouch = true; static void CallShmemCallbacksAfterStartup(const ShmemCallbacks *callbacks); +static void ProcessShmemRequestsAfterStartup(const ShmemCallbacks *callbacks); static void InitShmemIndexEntry(ShmemRequest *request); static bool AttachShmemIndexEntry(ShmemRequest *request, bool missing_ok); + static Size EstimateAllocatedSize(ShmemIndexEnt *entry); + static void ShmemProtectStructInternal(ShmemIndexEnt *entry); Datum pg_numa_available(PG_FUNCTION_ARGS); @@@ -356,19 -364,67 +382,80 @@@ ShmemRequestInternal(ShmemStructOpts *o if (options->name == NULL) elog(ERROR, "shared memory request is missing 'name' option"); ++<<<<<<< ours + if (options->size == SHMEM_ATTACH_UNKNOWN_SIZE) + { + if (ShmemIndex == NULL) + elog(ERROR, "SHMEM_ATTACH_UNKNOWN_SIZE cannot be used during startup"); ++======= + #ifndef HAVE_RESIZABLE_SHMEM + if (options->maximum_size > 0) + elog(ERROR, "resizable shared memory is not supported on this platform"); + if (options->minimum_size > 0) + elog(ERROR, "resizable shared memory is not supported on this platform"); + #else + if (options->maximum_size > 0 && shared_memory_type != SHMEM_TYPE_MMAP) + elog(ERROR, "resizable shared memory requires shared_memory_type = mmap"); + #endif + + if (IsUnderPostmaster) + { + if (options->size <= 0 && options->size != SHMEM_ATTACH_UNKNOWN_SIZE) + elog(ERROR, "invalid size %zd for shared memory request for \"%s\"", + options->size, options->name); + if (options->minimum_size < 0 && options->minimum_size != SHMEM_ATTACH_UNKNOWN_SIZE) + elog(ERROR, "invalid minimum_size %zd for shared memory request for \"%s\"", + options->minimum_size, options->name); + if (options->maximum_size < 0 && options->maximum_size != SHMEM_ATTACH_UNKNOWN_SIZE) + elog(ERROR, "invalid maximum_size %zd for shared memory request for \"%s\"", + options->maximum_size, options->name); + } + else + { + if (options->size == SHMEM_ATTACH_UNKNOWN_SIZE || + options->minimum_size == SHMEM_ATTACH_UNKNOWN_SIZE || + options->maximum_size == SHMEM_ATTACH_UNKNOWN_SIZE) + elog(ERROR, "SHMEM_ATTACH_UNKNOWN_SIZE cannot be used during startup"); + if (options->size <= 0) + elog(ERROR, "invalid size %zd for shared memory request for \"%s\"", + options->size, options->name); + if (options->minimum_size < 0) + elog(ERROR, "invalid minimum_size %zd for shared memory request for \"%s\"", + options->minimum_size, options->name); + if (options->maximum_size < 0) + elog(ERROR, "invalid maximum_size %zd for shared memory request for \"%s\"", + options->maximum_size, options->name); ++>>>>>>> theirs } + else if (options->size <= 0) + elog(ERROR, "invalid size %zd for shared memory request for \"%s\"", + options->size, options->name); if (options->alignment != 0 && pg_nextpower2_size_t(options->alignment) != options->alignment) elog(ERROR, "invalid alignment %zu for shared memory request for \"%s\"", options->alignment, options->name); ++<<<<<<< ours ++======= + if (options->minimum_size > 0 && options->size != SHMEM_ATTACH_UNKNOWN_SIZE && + options->minimum_size > options->size) + elog(ERROR, "resizable shared memory structure \"%s\" should have minimum size (%zd) less than or equal to size (%zd)", + options->name, options->minimum_size, options->size); + + if (options->maximum_size > 0 && options->size > options->maximum_size) + elog(ERROR, "resizable shared memory structure \"%s\" should have maximum size (%zd) greater than size (%zd)", + options->name, options->maximum_size, options->size); + + if (options->minimum_size > 0 && options->maximum_size > 0 && + options->minimum_size > options->maximum_size) + elog(ERROR, "resizable shared memory structure \"%s\" should have minimum size (%zd) less than or equal to maximum size (%zd)", + options->name, options->minimum_size, options->maximum_size); + + /* Check that we're in the right state */ + if (shmem_request_state != SRS_REQUESTING) + elog(ERROR, "ShmemRequestStruct can only be called from a shmem_request callback"); + ++>>>>>>> theirs /* Check that it's not already registered in this process */ foreach_ptr(ShmemRequest, existing, pending_shmem_requests) { @@@ -528,11 -626,9 +666,12 @@@ InitShmemIndexEntry(ShmemRequest *reque ShmemIndexEnt *index_entry; bool found; size_t allocated_size; + size_t requested_size; void *structPtr; + /* Size must be known at this point. */ + Assert(request->options->size != SHMEM_ATTACH_UNKNOWN_SIZE); + /* look it up in the shmem index */ index_entry = (ShmemIndexEnt *) hash_search(ShmemIndex, name, HASH_ENTER_NULL, &found); @@@ -567,13 -672,31 +715,36 @@@ index_entry->size = request->options->size; index_entry->allocated_size = allocated_size; index_entry->location = structPtr; + index_entry->reserved_space = allocated_size; + if (request->options->maximum_size > 0) + { + index_entry->minimum_size = request->options->minimum_size; + index_entry->maximum_size = request->options->maximum_size; + + /* Adjust allocated size of a resizable structure. */ + index_entry->allocated_size = EstimateAllocatedSize(index_entry); + + /* + * Protect the unused part of the reserved address space for a + * resizable structure. If the structure has same minimum and maximum + * size, it is effectively a fixed-size structure without any unused + * space; no protection is required. + */ + if (index_entry->minimum_size != index_entry->maximum_size) + ShmemProtectStructInternal(index_entry); + } + else + { + index_entry->minimum_size = request->options->size; + index_entry->maximum_size = request->options->size; + } - /* Initialize depending on the kind of shmem area it is */ + /* + * The area is considered fully initialized only after the subsystem's + * init callback has been called. For now, perform only basic + * initialization based on the kind of shmem area it is. + */ + index_entry->initialized = false; switch (request->kind) { case SHMEM_KIND_STRUCT: @@@ -619,21 -739,7 +790,25 @@@ AttachShmemIndexEntry(ShmemRequest *req return false; } ++<<<<<<< ours + /* + * If it was previously allocated but not fully initialized, error out. + * There is currently no way of retrying or cleaning up an uninitialized + * entry, it just lingers until the server is shut down. But this can + * only happen when allocating areas after postmaster startup, and it's + * unlikely that you could successfully retry anyway. The most likely + * reason for failed initialization is that you are out of shared memory + * and retrying won't help with that. + */ + if (!index_entry->initialized) + ereport(ERROR, + (errmsg("cannot attach to shared memory struct \"%s\" because it was not fully initialized", + request->options->name))); + + /* Check that the size in the index matches the request */ ++======= + /* Check that the sizes in the index match the request. */ ++>>>>>>> theirs if (index_entry->size != request->options->size && request->options->size != SHMEM_ATTACH_UNKNOWN_SIZE) { @@@ -772,8 -1198,10 +1269,11 @@@ InitShmemAllocator(PGShmemHeader *seghd Assert(!found); result->size = ShmemAllocator->index_size; result->allocated_size = ShmemAllocator->index_size; + result->minimum_size = result->size; + result->maximum_size = result->size; + result->reserved_space = result->allocated_size; result->location = ShmemAllocator->index; + result->initialized = true; } } @@@ -1377,22 -1763,9 +1896,26 @@@ pg_get_shmem_allocations_numa(PG_FUNCTI Size pg_get_shmem_pagesize(void) { ++<<<<<<< ours + Size os_page_size; +#ifdef WIN32 + SYSTEM_INFO sysinfo; + + GetSystemInfo(&sysinfo); + os_page_size = sysinfo.dwPageSize; +#else + os_page_size = sysconf(_SC_PAGESIZE); +#endif + + Assert(huge_pages_status != HUGE_PAGES_UNKNOWN); + + if (huge_pages_status == HUGE_PAGES_ON) + GetHugePageSize(&os_page_size, NULL); ++======= + Assert(IsUnderPostmaster); ++>>>>>>> theirs - return os_page_size; + return GetOSPageSize(); } Datum diff --cc src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl index 7f252af9987,d231821e0b4..00000000000 --- a/src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl +++ b/src/test/modules/test_shmem/t/001_fixed_shmem_struct.pl @@@ -46,183 -56,36 +46,216 @@@ els ); } + ### + # Test that a fixed-size shared memory structure cannot be resized. + # Only relevant on platforms that support resizable shmem. + ### + my $have_resizable_shmem = + $node->safe_psql('postgres', 'SHOW have_resizable_shmem;') eq 'on'; + + if ($have_resizable_shmem) + { + # Try expanding the fixed-size structure + my ($ret, $stdout, $stderr) = + $node->psql("postgres", "SELECT test_shmem_resize_fixed(1000);"); + isnt($ret, 0, "expanding a fixed-size structure fails"); + like($stderr, qr/is not resizable/, "expand error message mentions not resizable"); + + # Try shrinking the fixed-size structure + ($ret, $stdout, $stderr) = + $node->psql("postgres", "SELECT test_shmem_resize_fixed(1);"); + isnt($ret, 0, "shrinking a fixed-size structure fails"); + like($stderr, qr/is not resizable/, "shrink error message mentions not resizable"); + } + + ### + # Test that minimum_size and maximum_size equal size for a fixed-size structure + # in pg_shmem_allocations. + ### + is($node->safe_psql('postgres', + "SELECT minimum_size = size AND maximum_size = size FROM pg_shmem_allocations WHERE name = 'test_shmem area';"), + 't', "fixed-size structure has minimum_size = maximum_size = size"); + $node->stop; ++<<<<<<< ours +$node->adjust_conf('postgresql.conf', 'shared_preload_libraries', undef); + + +### +# Test allocating memory after startup, i.e. when the library is not +# in shared_preload_libraries +### +$node->start; + +# This first call to the function after startup loads the library +# and initializes the shmem area. +$attach_count1 = + $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();"); + +# Check that the attach counter is incremented on a new connection +$attach_count2 = + $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();"); +cmp_ok($attach_count2, '>', $attach_count1, + "attach callback is called in each backend"); + +# Allocate another shmem area, after the library has been loaded +my $res = $node->safe_psql("postgres", + "SELECT test_shmem_register('test_shmem after startup', 20, 1);"); +is($res, 0, 'allocate after startup'); + +# Test attaching to it again +$res = $node->safe_psql("postgres", + "SELECT test_shmem_register('test_shmem after startup', 20, 2);"); +is($res, 1, 'attach after startup'); + +# If the size doesn't match when attaching, you get an error +my (undef, undef, $stderr) = + $node->psql("postgres", + "SELECT test_shmem_register('test_shmem after startup', 25, 3);"); +like( + $stderr, + qr/ERROR: shared memory struct "test_shmem after startup" was created with different size: existing 20, requested 25/, + "attaching with different size fails"); + +# Test attaching with SHMEM_ATTACH_UNKNOWN_SIZE +$res = + $node->safe_psql("postgres", + "SELECT test_shmem_register('test_shmem after startup', -1, 4);"); +is($res, 2, 'attach with SHMEM_ATTACH_UNKNOWN_SIZE'); + +# Cannot use SHMEM_ATTACH_UNKNOWN_SIZE with a segment that doesn't exist +(undef, undef, $stderr) = + $node->psql("postgres", + "SELECT test_shmem_register('test_shmem missing area', -1, 5);"); +like( + $stderr, + qr/ERROR: cannot attach to shared memory struct "test_shmem missing area" because it does not exist/, + "unknown-size request for a nonexistent area fails"); + +$node->stop; + + +### +# Test a failure in initializing the shared memory area +### +SKIP: +{ + skip "injection points not supported by this build", 2 + if $ENV{enable_injection_points} ne 'yes'; + $node->start; + $node->safe_psql("postgres", "CREATE EXTENSION injection_points;"); + $node->safe_psql("postgres", + "SELECT injection_points_attach('test-shmem-init', 'error');"); + + # Try to load the extension library. It will hit the injected + # error in the init callback. + my (undef, undef, $stderr) = + $node->psql("postgres", "SELECT get_test_shmem_attach_count();"); + like( + $stderr, + qr/error triggered for injection point test-shmem-init/, + "failure in initialization is reported"); + $node->safe_psql("postgres", + "SELECT injection_points_detach('test-shmem-init');"); + + # The error leaves the shared memory area in a broken state. + # Attempting to initialize or attach it again will fail, until the + # server is restarted. + (undef, undef, $stderr) = + $node->psql("postgres", "SELECT get_test_shmem_attach_count();"); + like( + $stderr, + qr/cannot attach to shared memory/, + "post-init extension creation fails"); + + $node->stop; +} + + +### +# Test "out of shared memory" in an after-startup request +### + +# Huge pages round up the main shared memory segment, which can leave more +# unused space than the request below. Disable them to make the test reliable. +$node->append_conf('postgresql.conf', 'huge_pages = off'); +$node->start; +my $session = $node->background_psql('postgres', on_error_stop => 0); + +# make the request larger than the memory reserved for after-startup +# requests. +$session->query(q[SET test_shmem.area_size = '128kB';]); + +$session->query("SELECT get_test_shmem_attach_count();"); +like( + $session->{stderr}, + qr/not enough shared memory/, + "an after-startup request larger than the reserve fails"); + +# The server and the backend keep running. Since only one area was +# requested, it gets cleaned up on allocation failure. Verify that a +# request for a smaller area succeeds in the same session. +$session->{stderr} = ''; +$session->query("SET test_shmem.area_size = default;"); +$session->query_safe("SELECT get_test_shmem_attach_count();"); +$session->quit; +$node->stop; + + +### +# Test shmem allocations in single-user mode +### +SKIP: +{ + # Skip the test on Windows, as single-user mode would fail on permission + # failure with privileged accounts. + skip 'single-user test is not supported by this platform', 4 + if $windows_os; + + my @command = ( + 'postgres', '--single', '-F', + '-c' => 'exit_on_error=true', + '-D' => $node->data_dir); + + # The call to get_test_shmem_attach_count() loads the library and + # allocates the shmem area + my $queries = "SELECT get_test_shmem_attach_count();\n"; + my $result = run_log([ @command, 'postgres' ], '<' => \$queries); + ok($result, "shmem area is initialized in single-user mode"); + + # Test allocate and attach requests in a single-user session + $queries = qq{ +-- allocate +SELECT test_shmem_register('test_shmem after startup', 25, 1); +-- attach +SELECT test_shmem_register('test_shmem after startup', 25, 2); +-- attach with SHMEM_ATTACH_UNKNOWN_SIZE +SELECT test_shmem_register('test_shmem after startup', -1, 3); +}; + $result = run_log([ @command, 'postgres' ], '<' => \$queries); + ok($result, "allocate and attach in single-user mode"); + + # Cannot use SHMEM_ATTACH_UNKNOWN_SIZE with a segment that doesn't exist. + # We tested this in the after-startup tests already, but test it at startup, + # in single-user mode, too. + my $startup_stderr; + $result = run_log( + [ + @command, + '-c' => 'shared_preload_libraries=test_shmem', + '-c' => 'test_shmem.area_size=-1', + 'postgres' + ], + '<' => \'', + '2>' => \$startup_stderr); + ok(!$result, + "unknown-size request during single-user startup is rejected"); + like( + $startup_stderr, + qr/SHMEM_ATTACH_UNKNOWN_SIZE cannot be used during startup/, + "error message on rejected unknown-size request"); +} ++======= ++>>>>>>> theirs done_testing(); diff --cc src/test/modules/test_shmem/test_shmem--1.0.sql index 1dec3ce0d68,eb695604b1d..00000000000 --- a/src/test/modules/test_shmem/test_shmem--1.0.sql +++ b/src/test/modules/test_shmem/test_shmem--1.0.sql @@@ -8,6 -12,53 +12,59 @@@ CREATE FUNCTION get_test_shmem_attach_c RETURNS pg_catalog.int4 STRICT AS 'MODULE_PATHNAME' LANGUAGE C; ++<<<<<<< ours +CREATE FUNCTION test_shmem_register(pg_catalog.text, pg_catalog.int8, pg_catalog.int4) +RETURNS pg_catalog.int4 STRICT +AS 'MODULE_PATHNAME' LANGUAGE C; ++======= + CREATE FUNCTION test_shmem_resize_fixed(pg_catalog.int4) + RETURNS pg_catalog.void STRICT + AS 'MODULE_PATHNAME' LANGUAGE C; + + + -- =================================================================== + -- Resizable shared memory structure + -- =================================================================== + + -- Function to resize the test structure in the shared memory + CREATE FUNCTION resizable_shmem_resize(new_entries integer) + RETURNS bool + AS 'MODULE_PATHNAME' + LANGUAGE C STRICT; + + -- Function to write data to all entries in the test structure in shared memory + -- Writing all the entries makes sure that the memory is actually allocated and + -- mapped to the process, so that we can later measure the memory usage. + CREATE FUNCTION resizable_shmem_write(entry_value integer) + RETURNS void + AS 'MODULE_PATHNAME' + LANGUAGE C STRICT; + + -- Function to verify that specified number of initial entries have expected value. + -- Reading all the entries makes sure that the memory is actually mapped to the + -- process, so that we can later measure the memory usage. + CREATE FUNCTION resizable_shmem_read(entry_count integer, entry_value integer) + RETURNS boolean + AS 'MODULE_PATHNAME' + LANGUAGE C STRICT; + + -- Function to report memory mapped against the main shared memory segment in + -- the backend where this function runs. + CREATE FUNCTION test_shmem_usage() + RETURNS bigint + AS 'MODULE_PATHNAME' + LANGUAGE C STRICT; + + -- Function to get the shared memory page size + CREATE FUNCTION test_shmem_pagesize() + RETURNS integer + AS 'MODULE_PATHNAME' + LANGUAGE C STRICT; + + -- Function to crash the backend by walking entries past the current size up to + -- the reserved maximum, reading or writing each one as decided by mode. + CREATE FUNCTION resizable_shmem_access_beyond_size(mode text) + RETURNS integer + AS 'MODULE_PATHNAME' + LANGUAGE C STRICT; ++>>>>>>> theirs diff --cc src/test/modules/test_shmem/test_shmem.c index bb822ea30a8,83f8ea9cc3c..00000000000 --- a/src/test/modules/test_shmem/test_shmem.c +++ b/src/test/modules/test_shmem/test_shmem.c @@@ -22,38 -26,27 +26,36 @@@ #include "storage/shmem.h" #include "utils/builtins.h" #include "utils/guc.h" ++<<<<<<< ours +#include "utils/injection_point.h" ++======= ++>>>>>>> theirs PG_MODULE_MAGIC; + + /* ---------------------------------------------------------------- + * Fixed-size shared memory structure + * ---------------------------------------------------------------- + */ + typedef struct TestShmemData { - int value; bool initialized; int attach_count; + char dummy_data[FLEXIBLE_ARRAY_MEMBER]; } TestShmemData; static TestShmemData *TestShmem; +#define DEFAULT_TEST_AREA_BYTES sizeof(TestShmemData) +#define MAX_TEST_AREA_BYTES 1000000 + static bool attached_or_initialized = false; +static int test_shmem_area_size = DEFAULT_TEST_AREA_BYTES; +static bool test_shmem_guc_defined = false; - static void test_shmem_request(void *arg); - static void test_shmem_init(void *arg); - static void test_shmem_attach(void *arg); - - static const ShmemCallbacks TestShmemCallbacks = { - .flags = SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP, - .request_fn = test_shmem_request, - .init_fn = test_shmem_init, - .attach_fn = test_shmem_attach, - }; - static void test_shmem_request(void *arg) { @@@ -69,7 -62,15 +71,19 @@@ test_shmem_init(void *arg { elog(LOG, "init callback called"); ++<<<<<<< ours + INJECTION_POINT("test-shmem-init", NULL); ++======= + /* + * Reset the per-process flag and the shared "initialized" marker during + * postmaster induced restart. + */ + if (!IsUnderPostmaster) + { + attached_or_initialized = false; + TestShmem->initialized = false; + } ++>>>>>>> theirs if (TestShmem->initialized) elog(ERROR, "shmem area already initialized"); @@@ -93,32 -94,12 +107,41 @@@ test_shmem_attach(void *arg attached_or_initialized = true; } ++<<<<<<< ours +void +_PG_init(void) +{ + elog(LOG, "test_shmem module's _PG_init called"); + + if (!test_shmem_guc_defined) + { + /* + * The minimum size that makes sense is sizeof(TestShmemData), but we + * allow -1 so that we can test passing SHMEM_ATTACH_UNKNOWN_SIZE. + */ + DefineCustomIntVariable("test_shmem.area_size", + "Size of the shmem area to request.", + NULL, + &test_shmem_area_size, + DEFAULT_TEST_AREA_BYTES, + -1, + MAX_TEST_AREA_BYTES, + PGC_USERSET, + GUC_UNIT_BYTE, + NULL, NULL, NULL); + MarkGUCPrefixReserved("test_shmem"); + test_shmem_guc_defined = true; + } + RegisterShmemCallbacks(&TestShmemCallbacks); +} ++======= + static const ShmemCallbacks TestShmemCallbacks = { + .flags = SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP, + .request_fn = test_shmem_request, + .init_fn = test_shmem_init, + .attach_fn = test_shmem_attach, + }; ++>>>>>>> theirs PG_FUNCTION_INFO_V1(get_test_shmem_attach_count); Datum @@@ -131,56 -112,452 +154,507 @@@ get_test_shmem_attach_count(PG_FUNCTION PG_RETURN_INT32(TestShmem->attach_count); } ++<<<<<<< ours + +/* + * Callback for test_shmem_register(). test_shmem_register() provides the + * options, we just pass them through to ShmemRequestStruct. + */ +static void +test_shmem_after_startup_request(void *arg) +{ + ShmemStructOpts *opts = (ShmemStructOpts *) arg; + + elog(LOG, "test_shmem_after_startup_request callback called"); + + ShmemRequestStructWithOpts(opts); +} + +/* + * Allocate or attach to a shmem structure, with the caller-supplied name and + * size. + * + * The given integer 'new_value' is stored in the area, and the old value + * is returned. + */ +PG_FUNCTION_INFO_V1(test_shmem_register); +Datum +test_shmem_register(PG_FUNCTION_ARGS) +{ + char *name = text_to_cstring(PG_GETARG_TEXT_PP(0)); + int64 size = PG_GETARG_INT64(1); + int new_value = PG_GETARG_INT32(2); + int old_value; + int *attached = NULL; + + ShmemStructOpts opts = { + .name = name, + .size = size, + .ptr = (void **) &attached, + }; + + ShmemCallbacks callbacks = { + .flags = SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP, + .request_fn = test_shmem_after_startup_request, + .opaque_arg = &opts, + }; + + RegisterShmemCallbacks(&callbacks); + if (attached == NULL) + elog(ERROR, "could not attach to shared memory"); + + old_value = *attached; + *attached = new_value; + + PG_RETURN_INT32(old_value); ++======= + /* + * Attempt to resize the fixed-size shared memory structure. This should + * fail because the structure was not allocated with a maximum_size. + */ + PG_FUNCTION_INFO_V1(test_shmem_resize_fixed); + Datum + test_shmem_resize_fixed(PG_FUNCTION_ARGS) + { + int32 new_size = PG_GETARG_INT32(0); + + ShmemResizeStruct("test_shmem area", new_size); + PG_RETURN_VOID(); + } + + + /* ---------------------------------------------------------------- + * Resizable shared memory structure + * ---------------------------------------------------------------- + */ + + /* + * The test module may be loaded after postmaster startup in which case only + * 100K of shared memory is available for the extension. Keep the default + * initial and maximum sizes small enough to fit in that space. + */ + #define TEST_INITIAL_ENTRIES_DEFAULT 1 + #define TEST_MAX_ENTRIES_DEFAULT 1024 + + #define TEST_ENTRY_SIZE sizeof(int32) /* Size of each entry */ + + /* + * Resizable test data structure stored in shared memory. + * + * The test performs resizing, reads or writes, only one at a time and never + * concurrently. Hence, there is no need for locks in the test structure. + */ + typedef struct TestResizableShmemStruct + { + /* Metadata */ + int32 num_entries; /* Number of entries that can fit */ + + /* Data area - variable size */ + int32 data[FLEXIBLE_ARRAY_MEMBER]; + } TestResizableShmemStruct; + + static TestResizableShmemStruct *resizable_shmem = NULL; + + /* GUC variables controlling the size of the test structure */ + static int test_initial_entries; + static int test_max_entries; + + /* Whether to use SHMEM_ATTACH_UNKNOWN_SIZE when attaching to the shared memory */ + /* TODO: We may use opaque_arg to pass this value to the request function.*/ + static bool use_unknown_size = false; + + /* + * Request shared memory resources. + */ + static void + resizable_shmem_request(void *arg) + { + Size initial_size = add_size(offsetof(TestResizableShmemStruct, data), + mul_size(test_initial_entries, TEST_ENTRY_SIZE)); + + /* + * Create resizable structure on the platforms which support it. Otherwise create + * as a fixed-size structure. Other way would be to conditionally include + * .maximum_size in the call to ShmemRequestStruct(). + */ + #ifdef HAVE_RESIZABLE_SHMEM + Size max_size = add_size(offsetof(TestResizableShmemStruct, data), + mul_size(test_max_entries, TEST_ENTRY_SIZE)); + Size min_size = offsetof(TestResizableShmemStruct, data); + #else + Size max_size = 0; + Size min_size = 0; + #endif + + ShmemRequestStruct(.name = "resizable_shmem", + .size = use_unknown_size ? SHMEM_ATTACH_UNKNOWN_SIZE : initial_size, + .minimum_size = min_size, + .maximum_size = max_size, + .ptr = (void **) &resizable_shmem, + ); + } + + /* + * Initialize shared memory structure. + */ + static void + resizable_shmem_shmem_init(void *arg) + { + Assert(resizable_shmem != NULL); + + resizable_shmem->num_entries = test_initial_entries; + memset(resizable_shmem->data, 0, mul_size(test_initial_entries, TEST_ENTRY_SIZE)); + } + + /* + * Attach to the already-allocated shared memory structure. + */ + static void + resizable_shmem_shmem_attach(void *arg) + { + Assert(resizable_shmem != NULL); + } + + static ShmemCallbacks resizable_shmem_callbacks = { + .request_fn = resizable_shmem_request, + .init_fn = resizable_shmem_shmem_init, + .attach_fn = resizable_shmem_shmem_attach, + }; + + /* + * Resize the shared memory structure to accommodate the specified number of + * entries. + * + * Negative value for new_entries can be used to test resizing below the + * minimum size. + * + * Returns true if the resize was successful, false if ShmemResizeStruct() + * could not allocate the requested memory. On platforms that do not support + * resizable shared memory, ShmemResizeStruct() raises an error. + */ + PG_FUNCTION_INFO_V1(resizable_shmem_resize); + Datum + resizable_shmem_resize(PG_FUNCTION_ARGS) + { + int32 new_entries = PG_GETARG_INT32(0); + Size new_size; + + if (!resizable_shmem) + ereport(ERROR, + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("resizable_shmem is not initialized")); + + if (new_entries < 0) + new_size = 1; + else + new_size = add_size(offsetof(TestResizableShmemStruct, data), + mul_size(new_entries, TEST_ENTRY_SIZE)); + if (!ShmemResizeStruct("resizable_shmem", new_size)) + PG_RETURN_BOOL(false); + + ShmemProtectStruct("resizable_shmem"); + resizable_shmem->num_entries = new_entries; + + PG_RETURN_BOOL(true); + } + + /* + * Write the given integer value to all entries in the data array. + */ + PG_FUNCTION_INFO_V1(resizable_shmem_write); + Datum + resizable_shmem_write(PG_FUNCTION_ARGS) + { + int32 entry_value = PG_GETARG_INT32(0); + int32 i; + + if (!resizable_shmem) + ereport(ERROR, + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("resizable_shmem is not initialized")); + + #ifdef HAVE_RESIZABLE_SHMEM + + /* + * Ideally the structure should be protected through a synchronization + * cycle across all the backends that may access the structure. But we + * don't implement any such synchronization in this test module to keep it + * simple. Given that ProcSignalBarrier mechanism is not extensible, we + * may not be able to do that as well here. Hence add protect just before + * accessing the structure. + */ + ShmemProtectStruct("resizable_shmem"); + #endif + + for (i = 0; i < resizable_shmem->num_entries; i++) + resizable_shmem->data[i] = entry_value; + + PG_RETURN_VOID(); + } + + /* + * Check whether the first 'entry_count' entries all have the expected 'entry_value'. + * Returns true if all match, false otherwise. + */ + PG_FUNCTION_INFO_V1(resizable_shmem_read); + Datum + resizable_shmem_read(PG_FUNCTION_ARGS) + { + int32 entry_count = PG_GETARG_INT32(0); + int32 entry_value = PG_GETARG_INT32(1); + int32 i; + + if (resizable_shmem == NULL) + ereport(ERROR, + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("resizable_shmem is not initialized")); + + if (entry_count < 0 || entry_count > resizable_shmem->num_entries) + ereport(ERROR, + errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("entry_count %d is out of range (0..%d)", entry_count, resizable_shmem->num_entries)); + + #ifdef HAVE_RESIZABLE_SHMEM + + /* + * Ideally the structure should be protected through a synchronization + * cycle across all the backends that may access the structure. But we + * don't implement any such synchronization in this test module to keep it + * simple. Given that ProcSignalBarrier mechanism is not extensible, we + * may not be able to do that as well here. Hence add protect just before + * accessing the structure. + */ + ShmemProtectStruct("resizable_shmem"); + #endif + + for (i = 0; i < entry_count; i++) + { + if (resizable_shmem->data[i] != entry_value) + PG_RETURN_BOOL(false); + } + + PG_RETURN_BOOL(true); + } + + /* + * Return the memory mapped against the main shared memory segment in this + * backend. + * + * The VMA containing our resizable_shmem pointer identifies the start of the + * main shared-memory segment. + * + * mprotect() calls issued when the resizable structure grows and shrinks can + * split the original mmap into several adjacent VMAs, so we sum the accounting + * fields across the base VMA and any VMAs contiguous with it. + */ + PG_FUNCTION_INFO_V1(test_shmem_usage); + Datum + test_shmem_usage(PG_FUNCTION_ARGS) + { + FILE *f; + char line[256]; + uintptr_t target = (uintptr_t) resizable_shmem; + bool in_target_vma = false; + bool use_hugetlb = (huge_pages_status == HUGE_PAGES_ON); + unsigned long prev_end = 0; + int64 total_rss_kb = 0; + int64 total_swap_kb = 0; + int64 total_shared_hugetlb_kb = 0; + int64 val; + size_t result; + + f = AllocateFile("/proc/self/smaps", "r"); + if (f == NULL) + ereport(ERROR, + errcode_for_file_access(), + errmsg("could not open /proc/self/smaps: %m")); + + while (fgets(line, sizeof(line), f) != NULL) + { + unsigned long start; + unsigned long end; + + if (sscanf(line, "%lx-%lx", &start, &end) == 2) + { + if (in_target_vma) + { + /* + * Continue accumulating only across VMAs that are contiguous + * with the previous one; stop as soon as we hit a gap or a + * different mapping. + */ + if (start != prev_end) + break; + } + else + in_target_vma = (target >= start && target < end); + + prev_end = end; + } + else if (in_target_vma) + { + if (use_hugetlb) + { + if (sscanf(line, "Shared_Hugetlb: %ld kB", &val) == 1) + total_shared_hugetlb_kb += val; + } + else + { + if (sscanf(line, "Rss: %ld kB", &val) == 1) + total_rss_kb += val; + else if (sscanf(line, "Swap: %ld kB", &val) == 1) + total_swap_kb += val; + } + } + } + + FreeFile(f); + + if (use_hugetlb) + result = mul_size(total_shared_hugetlb_kb, 1024); + else + { + result = mul_size(total_rss_kb, 1024); + result = add_size(result, mul_size(total_swap_kb, 1024)); + } + + PG_RETURN_INT64(result); + } + + /* + * Return the shared memory page size. + */ + PG_FUNCTION_INFO_V1(test_shmem_pagesize); + Datum + test_shmem_pagesize(PG_FUNCTION_ARGS) + { + PG_RETURN_INT32(pg_get_shmem_pagesize()); + } + + /* + * Walk the entries between the current size and the reserved maximum, accessing + * each one. Ideally, this function should (seg)fault the moment we try to access + * the entry outside the currently allocated size, but the memory allocation and + * protection mechanisms work on page basis. Hence it may only (seg)fault when a + * page boundary is crossed. The mode argument selects between "read" and + * "write" access. + * + * When the current end of the structure and end of maximal structure are on the + * same page, this function may not (seg)fault at all. + */ + PG_FUNCTION_INFO_V1(resizable_shmem_access_beyond_size); + Datum + resizable_shmem_access_beyond_size(PG_FUNCTION_ARGS) + { + text *mode_txt = PG_GETARG_TEXT_PP(0); + const char *mode = text_to_cstring(mode_txt); + bool do_write; + int32 sink = 0; + + if (!resizable_shmem) + ereport(ERROR, + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("resizable_shmem is not initialized")); + + if (strcmp(mode, "read") == 0) + do_write = false; + else if (strcmp(mode, "write") == 0) + do_write = true; + else + ereport(ERROR, + errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("mode must be \"read\" or \"write\"")); + + #ifdef HAVE_RESIZABLE_SHMEM + + /* + * Ideally the structure should be protected through a synchronization + * cycle across all the backends that may access the structure. But we + * don't implement any such synchronization in this test module to keep it + * simple. Given that ProcSignalBarrier mechanism is not extensible, we + * may not be able to do that as well here. Hence add protect just before + * accessing the structure. + */ + ShmemProtectStruct("resizable_shmem"); + #endif + + for (int i = resizable_shmem->num_entries; i < test_max_entries; i++) + { + if (do_write) + resizable_shmem->data[i] = 0xdead; + else + sink = resizable_shmem->data[i]; + } + + /* + * Return the last read value so that compiler doesn't optimize away the + * assignment to sink. + */ + PG_RETURN_INT32(sink); + } + + + /* ---------------------------------------------------------------- + * Module initialization + * ---------------------------------------------------------------- + */ + + void + _PG_init(void) + { + int guc_context; + + elog(LOG, "test_shmem module's _PG_init called"); + + RegisterShmemCallbacks(&TestShmemCallbacks); + + /* + * Use PGC_POSTMASTER when loaded at startup so the values are fixed once + * the shared memory segment is created. When loaded after startup + * PGC_POSTMASTER is not allowed, so we use PGC_SIGHUP instead. Although + * we do not intend to change these values at config reload, PGC_SIGHUP is + * the least permissive context that allows defining the GUC after startup + * and still prevents it from being changed via SET. + */ + if (process_shared_preload_libraries_in_progress) + guc_context = PGC_POSTMASTER; + else + { + guc_context = PGC_SIGHUP; + resizable_shmem_callbacks.flags = SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP; + } + + DefineCustomIntVariable("resizable_shmem.initial_entries", + "Initial number of entries in the test structure.", + NULL, + &test_initial_entries, + TEST_INITIAL_ENTRIES_DEFAULT, + 1, + INT_MAX, + guc_context, + 0, + NULL, NULL, NULL); + + DefineCustomIntVariable("resizable_shmem.max_entries", + "Maximum number of entries in the test structure.", + NULL, + &test_max_entries, + TEST_MAX_ENTRIES_DEFAULT, + 1, + INT_MAX, + guc_context, + 0, + NULL, NULL, NULL); + + /* + * When loaded after startup by a backend that is not creating the + * extension, the shared memory might have been resized to a size other + * than the initial size. Use SHMEM_ATTACH_UNKNOWN_SIZE to attach without + * knowing the exact size. + */ + if (!process_shared_preload_libraries_in_progress && !creating_extension) + use_unknown_size = true; + + RegisterShmemCallbacks(&resizable_shmem_callbacks); ++>>>>>>> theirs } diff --cc src/tools/pgindent/typedefs.list index f10eb469266,a823271262c..00000000000 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@@ -3171,7 -3186,7 +3171,11 @@@ TestDSMRegistryHashEntr TestDSMRegistryStruct TestDecodingData TestDecodingTxnData ++<<<<<<< ours +TestExtNode ++======= + TestResizableShmemStruct ++>>>>>>> theirs TestShmemData TestSpec TestValueType