=== Applying patches on top of PostgreSQL commit ID 2ae459b08523ab110d1e2d60b46eb6bcd253bbdc === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Aug 13 15:37:49 UTC 2026 On branch cf/7145 nothing to commit, working tree clean === using 'git am' to apply patch ./v1-0001-pgstat-allow-a-stats-kind-to-use-its-own-dedicate.patch === Applying: pgstat: allow a stats kind to use its own dedicated dshash Using index info to reconstruct a base tree... M src/backend/utils/activity/pgstat.c M src/backend/utils/activity/pgstat_shmem.c M src/include/utils/pgstat_internal.h Falling back to patching base and 3-way merge... Auto-merging src/include/utils/pgstat_internal.h Auto-merging src/backend/utils/activity/pgstat_shmem.c CONFLICT (content): Merge conflict in src/backend/utils/activity/pgstat_shmem.c Auto-merging src/backend/utils/activity/pgstat.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 pgstat: allow a stats kind to use its own dedicated dshash 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 ./v1-0001-pgstat-allow-a-stats-kind-to-use-its-own-dedicate.patch === patching file src/backend/utils/activity/pgstat.c Hunk #1 succeeded at 1199 (offset 16 lines). Hunk #2 succeeded at 1587 (offset 31 lines). Hunk #3 succeeded at 1746 (offset 31 lines). Hunk #4 succeeded at 2106 (offset 31 lines). Hunk #5 succeeded at 2119 (offset 31 lines). patching file src/backend/utils/activity/pgstat_shmem.c Hunk #9 FAILED at 503. Hunk #10 succeeded at 596 (offset 19 lines). Hunk #11 succeeded at 640 (offset 19 lines). Hunk #12 FAILED at 634. Hunk #13 FAILED at 644. Hunk #14 succeeded at 738 (offset 38 lines). Hunk #15 succeeded at 787 (offset 38 lines). Hunk #16 succeeded at 812 (offset 38 lines). Hunk #17 succeeded at 1026 (offset 38 lines). Hunk #18 succeeded at 1069 (offset 38 lines). Hunk #19 succeeded at 1099 (offset 38 lines). Hunk #20 succeeded at 1167 (offset 38 lines). Hunk #21 succeeded at 1181 (offset 38 lines). Hunk #22 succeeded at 1201 (offset 38 lines). Hunk #23 succeeded at 1213 (offset 38 lines). Hunk #24 succeeded at 1287 (offset 38 lines). Hunk #25 succeeded at 1298 (offset 38 lines). 3 out of 25 hunks FAILED -- saving rejects to file src/backend/utils/activity/pgstat_shmem.c.rej patching file src/include/utils/pgstat_internal.h Hunk #2 succeeded at 561 (offset 6 lines). Hunk #3 succeeded at 655 (offset 6 lines). Hunk #4 succeeded at 1087 (offset 16 lines). patching file src/test/modules/test_custom_stats/t/001_custom_stats.pl patching file src/test/modules/test_custom_stats/test_custom_var_stats--1.0.sql patching file src/test/modules/test_custom_stats/test_custom_var_stats.c Unstaged changes after reset: M src/backend/utils/activity/pgstat.c M src/backend/utils/activity/pgstat_shmem.c M src/include/utils/pgstat_internal.h M src/test/modules/test_custom_stats/t/001_custom_stats.pl M src/test/modules/test_custom_stats/test_custom_var_stats--1.0.sql M src/test/modules/test_custom_stats/test_custom_var_stats.c Removing src/backend/utils/activity/pgstat_shmem.c.rej === using 'git apply' to apply patch ./v1-0001-pgstat-allow-a-stats-kind-to-use-its-own-dedicate.patch === Applied patch to 'src/backend/utils/activity/pgstat.c' cleanly. Applied patch to 'src/backend/utils/activity/pgstat_shmem.c' with conflicts. Applied patch to 'src/include/utils/pgstat_internal.h' cleanly. Applied patch to 'src/test/modules/test_custom_stats/t/001_custom_stats.pl' cleanly. Applied patch to 'src/test/modules/test_custom_stats/test_custom_var_stats--1.0.sql' cleanly. Applied patch to 'src/test/modules/test_custom_stats/test_custom_var_stats.c' cleanly. U src/backend/utils/activity/pgstat_shmem.c diff --cc src/backend/utils/activity/pgstat_shmem.c index d8ac9d6f5e8,04b17db9ee7..00000000000 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@@ -404,6 -503,8 +503,11 @@@ pgstat_acquire_entry_ref(PgStat_EntryRe pg_atomic_fetch_add_u32(&shhashent->refcount, 1); ++<<<<<<< ours ++======= + dshash_release_lock(pgstat_get_hash_for_kind(shhashent->key.kind), shhashent); + ++>>>>>>> theirs entry_ref->shared_stats = shheader; entry_ref->shared_entry = shhashent; entry_ref->generation = pg_atomic_read_u32(&shhashent->generation); @@@ -551,36 -634,17 +658,44 @@@ pgstat_get_entry_ref(PgStat_Kind kind, * lookup. If so, fall through to the same path as if we'd have if it * already had been created before the dshash_find() calls. */ ++<<<<<<< ours + shhashent = dshash_find_or_insert_extended(pgStatLocal.shared_hash, + &key, &shfound, + DSHASH_INSERT_NO_OOM); + if (!shhashent) + { + /* + * Clean up the local reference when failing insert into the + * shared hashtable. + */ + pgstat_release_entry_ref(key, entry_ref, false); + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"), + errdetail("Failed while inserting entry %u/%u/%" PRIu64 ".", + key.kind, key.dboid, key.objid))); + } + ++======= + shhashent = dshash_find_or_insert(hash, &key, &shfound); ++>>>>>>> theirs if (!shfound) { shheader = pgstat_init_entry(kind, shhashent); if (shheader == NULL) { /* - * Failed the allocation of a new entry, so clean up the - * shared hashtable before giving up. + * Failed the allocation of a new entry, so clean up both the + * local reference and the shared hashtable before giving up. + * Clean the local state first, since releasing the dshash + * lock can process a pending interrupt. */ ++<<<<<<< ours + pgstat_release_entry_ref(key, entry_ref, false); + dshash_delete_entry(pgStatLocal.shared_hash, shhashent); ++======= + dshash_delete_entry(hash, shhashent); ++>>>>>>> theirs ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY),