=== Applying patches on top of PostgreSQL commit ID 901ed9b352b41f034e17bc540725082a488fce31 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sun May 10 00:57:24 UTC 2026 On branch cf/6419 nothing to commit, working tree clean === using 'git am' to apply patch ./v6-0001-Convert-wait_event_info-to-64-t-bits-expose-lower.patch === Applying: Convert wait_event_info to 64-t bits, expose lower 32-bit as new wait_event_arg Using index info to reconstruct a base tree... M contrib/dblink/dblink.c M contrib/postgres_fdw/connection.c M src/backend/access/transam/xlogarchive.c M src/backend/access/transam/xlogwait.c M src/backend/catalog/system_views.sql M src/backend/replication/walsender.c M src/backend/storage/buffer/bufmgr.c M src/backend/storage/file/fd.c M src/backend/storage/ipc/latch.c M src/backend/storage/ipc/standby.c M src/backend/storage/ipc/waiteventset.c M src/backend/storage/lmgr/lwlock.c M src/backend/storage/lmgr/proc.c M src/backend/storage/smgr/md.c M src/backend/utils/activity/backend_status.c M src/backend/utils/activity/wait_event.c M src/backend/utils/adt/misc.c M src/backend/utils/adt/pgstatfuncs.c M src/include/catalog/pg_proc.dat M src/include/storage/latch.h M src/include/storage/lwlock.h M src/include/storage/proc.h M src/include/utils/wait_event.h M src/test/modules/injection_points/injection_points.c M src/test/modules/test_shm_mq/setup.c M src/test/modules/test_shm_mq/test.c M src/test/modules/worker_spi/worker_spi.c M src/test/regress/expected/rules.out Falling back to patching base and 3-way merge... Auto-merging src/test/regress/expected/rules.out Auto-merging src/test/modules/worker_spi/worker_spi.c Auto-merging src/test/modules/test_shm_mq/test.c Auto-merging src/test/modules/test_shm_mq/setup.c Auto-merging src/test/modules/injection_points/injection_points.c Auto-merging src/include/utils/wait_event.h CONFLICT (content): Merge conflict in src/include/utils/wait_event.h Auto-merging src/include/storage/proc.h Auto-merging src/include/storage/lwlock.h Auto-merging src/include/storage/latch.h Auto-merging src/include/catalog/pg_proc.dat Auto-merging src/backend/utils/adt/pgstatfuncs.c Auto-merging src/backend/utils/adt/misc.c Auto-merging src/backend/utils/activity/wait_event.c CONFLICT (content): Merge conflict in src/backend/utils/activity/wait_event.c Auto-merging src/backend/utils/activity/backend_status.c Auto-merging src/backend/storage/smgr/md.c Auto-merging src/backend/storage/lmgr/proc.c Auto-merging src/backend/storage/lmgr/lwlock.c Auto-merging src/backend/storage/ipc/waiteventset.c Auto-merging src/backend/storage/ipc/standby.c Auto-merging src/backend/storage/ipc/latch.c Auto-merging src/backend/storage/file/fd.c Auto-merging src/backend/storage/buffer/bufmgr.c Auto-merging src/backend/replication/walsender.c Auto-merging src/backend/catalog/system_views.sql Auto-merging src/backend/access/transam/xlogwait.c Auto-merging src/backend/access/transam/xlogarchive.c Auto-merging contrib/postgres_fdw/connection.c Auto-merging contrib/dblink/dblink.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Convert wait_event_info to 64-t bits, expose lower 32-bit as new wait_event_arg 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 ./v6-0001-Convert-wait_event_info-to-64-t-bits-expose-lower.patch === patching file contrib/dblink/dblink.c Hunk #1 succeeded at 145 (offset 2 lines). patching file contrib/postgres_fdw/connection.c Hunk #1 succeeded at 94 with fuzz 1 (offset 8 lines). patching file src/backend/access/transam/xlogarchive.c Hunk #1 succeeded at 294 (offset 1 line). patching file src/backend/access/transam/xlogwait.c Hunk #1 succeeded at 81 (offset 10 lines). patching file src/backend/catalog/system_views.sql Hunk #1 succeeded at 954 (offset 18 lines). patching file src/backend/replication/walsender.c Hunk #1 succeeded at 311 with fuzz 2 (offset 29 lines). Hunk #2 succeeded at 1823 (offset 42 lines). Hunk #3 succeeded at 1856 (offset 42 lines). Hunk #4 succeeded at 1886 (offset 42 lines). Hunk #5 succeeded at 4030 (offset 202 lines). patching file src/backend/storage/buffer/bufmgr.c Hunk #1 succeeded at 5920 (offset 142 lines). patching file src/backend/storage/file/fd.c Hunk #1 succeeded at 2064 (offset 1 line). Hunk #2 succeeded at 2120 (offset 1 line). Hunk #3 succeeded at 2147 (offset 1 line). Hunk #4 succeeded at 2204 (offset 1 line). Hunk #5 succeeded at 2229 (offset 1 line). Hunk #6 succeeded at 2333 (offset 1 line). Hunk #7 succeeded at 2360 (offset 1 line). Hunk #8 succeeded at 2405 (offset 1 line). Hunk #9 succeeded at 2462 (offset 1 line). patching file src/backend/storage/ipc/barrier.c patching file src/backend/storage/ipc/latch.c patching file src/backend/storage/ipc/standby.c Hunk #1 succeeded at 73 (offset 1 line). Hunk #2 succeeded at 232 (offset 1 line). Hunk #3 succeeded at 360 (offset 1 line). Hunk #4 succeeded at 559 (offset 2 lines). patching file src/backend/storage/ipc/waiteventset.c Hunk #1 succeeded at 1039 (offset 1 line). patching file src/backend/storage/lmgr/condition_variable.c patching file src/backend/storage/lmgr/lwlock.c Hunk #1 succeeded at 690 (offset -28 lines). Hunk #2 succeeded at 744 (offset -26 lines). patching file src/backend/storage/lmgr/proc.c Hunk #1 succeeded at 521 (offset 13 lines). Hunk #2 succeeded at 1459 (offset 15 lines). Hunk #3 succeeded at 2012 (offset 44 lines). patching file src/backend/storage/lmgr/s_lock.c patching file src/backend/storage/smgr/md.c Hunk #1 succeeded at 749 (offset 1 line). patching file src/backend/utils/activity/backend_status.c Hunk #1 succeeded at 22 with fuzz 2 (offset 2 lines). Hunk #2 succeeded at 567 (offset -35 lines). patching file src/backend/utils/activity/generate-wait_event_types.pl patching file src/backend/utils/activity/wait_event.c Hunk #1 FAILED at 22. Hunk #2 succeeded at 38 (offset 2 lines). Hunk #4 succeeded at 96 with fuzz 2. Hunk #5 FAILED at 136. Hunk #6 succeeded at 147 (offset -14 lines). Hunk #7 succeeded at 190 (offset -14 lines). Hunk #8 succeeded at 199 (offset -14 lines). Hunk #9 succeeded at 214 (offset -14 lines). Hunk #10 succeeded at 224 (offset -14 lines). Hunk #11 succeeded at 238 (offset -14 lines). Hunk #12 succeeded at 270 (offset -14 lines). Hunk #13 succeeded at 288 (offset -14 lines). Hunk #14 succeeded at 300 (offset -14 lines). Hunk #15 succeeded at 343 (offset -14 lines). Hunk #16 succeeded at 367 (offset -14 lines). Hunk #17 succeeded at 425 (offset -14 lines). Hunk #18 succeeded at 436 (offset -14 lines). Hunk #19 succeeded at 450 (offset -14 lines). Hunk #20 succeeded at 504 (offset -14 lines). 2 out of 20 hunks FAILED -- saving rejects to file src/backend/utils/activity/wait_event.c.rej patching file src/backend/utils/adt/misc.c Hunk #1 succeeded at 379 (offset 2 lines). patching file src/backend/utils/adt/pgstatfuncs.c Hunk #1 FAILED at 30. Hunk #2 succeeded at 355 (offset 4 lines). Hunk #3 succeeded at 374 (offset 4 lines). Hunk #4 succeeded at 403 (offset 4 lines). Hunk #5 succeeded at 450 (offset 4 lines). Hunk #6 succeeded at 471 (offset 4 lines). Hunk #7 succeeded at 488 (offset 4 lines). Hunk #8 succeeded at 497 (offset 4 lines). Hunk #9 succeeded at 513 (offset 4 lines). Hunk #10 succeeded at 525 (offset 4 lines). Hunk #11 succeeded at 571 (offset 4 lines). Hunk #12 succeeded at 595 (offset 4 lines). Hunk #13 succeeded at 614 (offset 4 lines). Hunk #14 succeeded at 705 (offset 4 lines). Hunk #15 succeeded at 843 (offset 5 lines). Hunk #16 succeeded at 870 (offset 5 lines). 1 out of 16 hunks FAILED -- saving rejects to file src/backend/utils/adt/pgstatfuncs.c.rej patching file src/backend/utils/adt/waitfuncs.c patching file src/include/access/xlogarchive.h patching file src/include/catalog/pg_proc.dat Hunk #1 succeeded at 5689 (offset 26 lines). patching file src/include/libpq/libpq-be-fe-helpers.h patching file src/include/storage/barrier.h patching file src/include/storage/condition_variable.h patching file src/include/storage/fd.h patching file src/include/storage/latch.h Hunk #1 succeeded at 134 (offset 2 lines). patching file src/include/storage/lwlock.h Hunk #1 succeeded at 128 with fuzz 1 (offset -10 lines). patching file src/include/storage/proc.h Hunk #1 succeeded at 381 with fuzz 2 (offset 8 lines). Hunk #2 succeeded at 574 (offset -1 lines). patching file src/include/storage/waiteventset.h patching file src/include/utils/wait_classes.h patching file src/include/utils/wait_event.h Hunk #2 FAILED at 41. Hunk #3 succeeded at 66 (offset -2 lines). Hunk #4 succeeded at 85 (offset -2 lines). 1 out of 4 hunks FAILED -- saving rejects to file src/include/utils/wait_event.h.rej patching file src/test/modules/injection_points/injection_points.c Hunk #1 succeeded at 251 (offset -16 lines). patching file src/test/modules/test_shm_mq/setup.c Hunk #1 succeeded at 42 (offset 1 line). patching file src/test/modules/test_shm_mq/test.c Hunk #1 succeeded at 31 (offset 1 line). patching file src/test/modules/worker_spi/worker_spi.c Hunk #1 succeeded at 54 (offset 1 line). patching file src/test/regress/expected/rules.out Hunk #2 succeeded at 1945 (offset 16 lines). Hunk #3 succeeded at 2248 (offset 89 lines). Hunk #4 succeeded at 2285 (offset 89 lines). Unstaged changes after reset: M contrib/dblink/dblink.c M contrib/postgres_fdw/connection.c M src/backend/access/transam/xlogarchive.c M src/backend/access/transam/xlogwait.c M src/backend/catalog/system_views.sql M src/backend/replication/walsender.c M src/backend/storage/buffer/bufmgr.c M src/backend/storage/file/fd.c M src/backend/storage/ipc/barrier.c M src/backend/storage/ipc/latch.c M src/backend/storage/ipc/standby.c M src/backend/storage/ipc/waiteventset.c M src/backend/storage/lmgr/condition_variable.c M src/backend/storage/lmgr/lwlock.c M src/backend/storage/lmgr/proc.c M src/backend/storage/lmgr/s_lock.c M src/backend/storage/smgr/md.c M src/backend/utils/activity/backend_status.c M src/backend/utils/activity/generate-wait_event_types.pl M src/backend/utils/activity/wait_event.c M src/backend/utils/adt/misc.c M src/backend/utils/adt/pgstatfuncs.c M src/backend/utils/adt/waitfuncs.c M src/include/access/xlogarchive.h M src/include/catalog/pg_proc.dat M src/include/libpq/libpq-be-fe-helpers.h M src/include/storage/barrier.h M src/include/storage/condition_variable.h M src/include/storage/fd.h M src/include/storage/latch.h M src/include/storage/lwlock.h M src/include/storage/proc.h M src/include/storage/waiteventset.h M src/include/utils/wait_classes.h M src/include/utils/wait_event.h M src/test/modules/injection_points/injection_points.c M src/test/modules/test_shm_mq/setup.c M src/test/modules/test_shm_mq/test.c M src/test/modules/worker_spi/worker_spi.c M src/test/regress/expected/rules.out Removing src/backend/utils/activity/wait_event.c.rej Removing src/backend/utils/adt/pgstatfuncs.c.rej Removing src/include/utils/wait_event.h.rej === using 'git apply' to apply patch ./v6-0001-Convert-wait_event_info-to-64-t-bits-expose-lower.patch === Applied patch to 'contrib/dblink/dblink.c' cleanly. Applied patch to 'contrib/postgres_fdw/connection.c' cleanly. Applied patch to 'src/backend/access/transam/xlogarchive.c' cleanly. Applied patch to 'src/backend/access/transam/xlogwait.c' cleanly. Applied patch to 'src/backend/catalog/system_views.sql' cleanly. Applied patch to 'src/backend/replication/walsender.c' cleanly. Applied patch to 'src/backend/storage/buffer/bufmgr.c' cleanly. Applied patch to 'src/backend/storage/file/fd.c' cleanly. Applied patch to 'src/backend/storage/ipc/barrier.c' cleanly. Applied patch to 'src/backend/storage/ipc/latch.c' cleanly. Applied patch to 'src/backend/storage/ipc/standby.c' cleanly. Applied patch to 'src/backend/storage/ipc/waiteventset.c' cleanly. Applied patch to 'src/backend/storage/lmgr/condition_variable.c' cleanly. Applied patch to 'src/backend/storage/lmgr/lwlock.c' cleanly. Applied patch to 'src/backend/storage/lmgr/proc.c' cleanly. Applied patch to 'src/backend/storage/lmgr/s_lock.c' cleanly. Applied patch to 'src/backend/storage/smgr/md.c' cleanly. Applied patch to 'src/backend/utils/activity/backend_status.c' cleanly. Applied patch to 'src/backend/utils/activity/generate-wait_event_types.pl' cleanly. Applied patch to 'src/backend/utils/activity/wait_event.c' with conflicts. Applied patch to 'src/backend/utils/adt/misc.c' cleanly. Applied patch to 'src/backend/utils/adt/pgstatfuncs.c' cleanly. Applied patch to 'src/backend/utils/adt/waitfuncs.c' cleanly. Applied patch to 'src/include/access/xlogarchive.h' cleanly. Applied patch to 'src/include/catalog/pg_proc.dat' cleanly. Applied patch to 'src/include/libpq/libpq-be-fe-helpers.h' cleanly. Applied patch to 'src/include/storage/barrier.h' cleanly. Applied patch to 'src/include/storage/condition_variable.h' cleanly. Applied patch to 'src/include/storage/fd.h' cleanly. Applied patch to 'src/include/storage/latch.h' cleanly. Applied patch to 'src/include/storage/lwlock.h' cleanly. Applied patch to 'src/include/storage/proc.h' cleanly. Applied patch to 'src/include/storage/waiteventset.h' cleanly. Applied patch to 'src/include/utils/wait_classes.h' cleanly. Applied patch to 'src/include/utils/wait_event.h' with conflicts. Applied patch to 'src/test/modules/injection_points/injection_points.c' cleanly. Applied patch to 'src/test/modules/test_shm_mq/setup.c' cleanly. Applied patch to 'src/test/modules/test_shm_mq/test.c' cleanly. Applied patch to 'src/test/modules/worker_spi/worker_spi.c' cleanly. Applied patch to 'src/test/regress/expected/rules.out' cleanly. U src/backend/utils/activity/wait_event.c U src/include/utils/wait_event.h diff --cc src/backend/utils/activity/wait_event.c index 95635c7f56c,e878c892379..00000000000 --- a/src/backend/utils/activity/wait_event.c +++ b/src/backend/utils/activity/wait_event.c @@@ -22,10 -22,9 +22,16 @@@ */ #include "postgres.h" ++<<<<<<< ours +#include "storage/lmgr.h" +#include "storage/lwlock.h" +#include "storage/shmem.h" +#include "storage/subsystems.h" ++======= + #include "port/atomics.h" + #include "storage/lmgr.h" /* for GetLockNameFromTagType */ + #include "storage/lwlock.h" /* for GetLWLockIdentifier */ ++>>>>>>> theirs #include "storage/spin.h" #include "utils/wait_event.h" @@@ -93,50 -97,64 +102,86 @@@ static WaitEventCustomCounterData *Wait /* first event ID of custom wait events */ #define WAIT_EVENT_CUSTOM_INITIAL_ID 1 - static uint32 WaitEventCustomNew(uint32 classId, const char *wait_event_name); - static const char *GetWaitEventCustomIdentifier(uint32 wait_event_info); + static uint64 WaitEventCustomNew(uint64 classId, const char *wait_event_name); + static const char *GetWaitEventCustomIdentifier(uint64 wait_event_info); +static void WaitEventCustomShmemRequest(void *arg); +static void WaitEventCustomShmemInit(void *arg); + +const ShmemCallbacks WaitEventCustomShmemCallbacks = { + .request_fn = WaitEventCustomShmemRequest, + .init_fn = WaitEventCustomShmemInit, +}; + /* - * Return the space for dynamic shared hash tables and dynamic allocation counter. + * Register shmem space for dynamic shared hash and dynamic allocation counter. */ -Size -WaitEventCustomShmemSize(void) +static void +WaitEventCustomShmemRequest(void *arg) { - Size sz; - - sz = MAXALIGN(sizeof(WaitEventCustomCounterData)); - sz = add_size(sz, hash_estimate_size(WAIT_EVENT_CUSTOM_HASH_MAX_SIZE, - sizeof(WaitEventCustomEntryByInfo))); - sz = add_size(sz, hash_estimate_size(WAIT_EVENT_CUSTOM_HASH_MAX_SIZE, - sizeof(WaitEventCustomEntryByName))); - return sz; + ShmemRequestStruct(.name = "WaitEventCustomCounterData", + .size = sizeof(WaitEventCustomCounterData), + .ptr = (void **) &WaitEventCustomCounter, + ); + ShmemRequestHash(.name = "WaitEventCustom hash by wait event information", + .ptr = &WaitEventCustomHashByInfo, + .nelems = WAIT_EVENT_CUSTOM_HASH_SIZE, + .hash_info.keysize = sizeof(uint32), + .hash_info.entrysize = sizeof(WaitEventCustomEntryByInfo), + .hash_flags = HASH_ELEM | HASH_BLOBS, + ); + ShmemRequestHash(.name = "WaitEventCustom hash by name", + .ptr = &WaitEventCustomHashByName, + .nelems = WAIT_EVENT_CUSTOM_HASH_SIZE, + /* key is a NULL-terminated string */ + .hash_info.keysize = sizeof(char[NAMEDATALEN]), + .hash_info.entrysize = sizeof(WaitEventCustomEntryByName), + .hash_flags = HASH_ELEM | HASH_STRINGS, + ); } -/* - * Allocate shmem space for dynamic shared hash and dynamic allocation counter. - */ -void -WaitEventCustomShmemInit(void) +static void +WaitEventCustomShmemInit(void *arg) { ++<<<<<<< ours + /* initialize the allocation counter and its spinlock. */ + WaitEventCustomCounter->nextId = WAIT_EVENT_CUSTOM_INITIAL_ID; + SpinLockInit(&WaitEventCustomCounter->mutex); ++======= + bool found; + HASHCTL info; + + WaitEventCustomCounter = (WaitEventCustomCounterData *) + ShmemInitStruct("WaitEventCustomCounterData", + sizeof(WaitEventCustomCounterData), &found); + + if (!found) + { + /* initialize the allocation counter and its spinlock. */ + WaitEventCustomCounter->nextId = WAIT_EVENT_CUSTOM_INITIAL_ID; + SpinLockInit(&WaitEventCustomCounter->mutex); + } + + /* initialize or attach the hash tables to store custom wait events */ + info.keysize = sizeof(uint64); + info.entrysize = sizeof(WaitEventCustomEntryByInfo); + WaitEventCustomHashByInfo = + ShmemInitHash("WaitEventCustom hash by wait event information", + WAIT_EVENT_CUSTOM_HASH_INIT_SIZE, + WAIT_EVENT_CUSTOM_HASH_MAX_SIZE, + &info, + HASH_ELEM | HASH_BLOBS); + + /* key is a NULL-terminated string */ + info.keysize = sizeof(char[NAMEDATALEN]); + info.entrysize = sizeof(WaitEventCustomEntryByName); + WaitEventCustomHashByName = + ShmemInitHash("WaitEventCustom hash by name", + WAIT_EVENT_CUSTOM_HASH_INIT_SIZE, + WAIT_EVENT_CUSTOM_HASH_MAX_SIZE, + &info, + HASH_ELEM | HASH_STRINGS); ++>>>>>>> theirs } /* diff --cc src/include/utils/wait_event.h index 86ee348220d,a3a33bfd208..00000000000 --- a/src/include/utils/wait_event.h +++ b/src/include/utils/wait_event.h @@@ -39,10 -41,12 +41,16 @@@ extern PGDLLIMPORT volatile pg_atomic_u * * The ID retrieved can be used with pgstat_report_wait_start() or equivalent. */ - extern uint32 WaitEventExtensionNew(const char *wait_event_name); - extern uint32 WaitEventInjectionPointNew(const char *wait_event_name); + extern uint64 WaitEventExtensionNew(const char *wait_event_name); + extern uint64 WaitEventInjectionPointNew(const char *wait_event_name); ++<<<<<<< ours +extern char **GetWaitEventCustomNames(uint32 classId, int *nwaitevents); ++======= + extern void WaitEventCustomShmemInit(void); + extern Size WaitEventCustomShmemSize(void); + extern char **GetWaitEventCustomNames(uint64 classId, int *nwaitevents); ++>>>>>>> theirs /* ---------- * pgstat_report_wait_start() -