=== Applying patches on top of PostgreSQL commit ID 82467f627bd478569de04f4a3f1993098e80c812 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Mar 11 04:36:23 UTC 2026 On branch cf/6570 nothing to commit, working tree clean === using 'git am' to apply patch ./v4-0001-Fix-DSA-pagemap-undersizing-in-make_new_segment.patch === Applying: Fix DSA pagemap undersizing in make_new_segment. Using index info to reconstruct a base tree... M src/backend/utils/mmgr/dsa.c M src/test/modules/test_dsa/expected/test_dsa.out M src/test/modules/test_dsa/sql/test_dsa.sql M src/test/modules/test_dsa/test_dsa--1.0.sql M src/test/modules/test_dsa/test_dsa.c Falling back to patching base and 3-way merge... Auto-merging src/test/modules/test_dsa/test_dsa.c CONFLICT (content): Merge conflict in src/test/modules/test_dsa/test_dsa.c Auto-merging src/test/modules/test_dsa/test_dsa--1.0.sql CONFLICT (content): Merge conflict in src/test/modules/test_dsa/test_dsa--1.0.sql Auto-merging src/test/modules/test_dsa/sql/test_dsa.sql CONFLICT (content): Merge conflict in src/test/modules/test_dsa/sql/test_dsa.sql Auto-merging src/test/modules/test_dsa/expected/test_dsa.out CONFLICT (content): Merge conflict in src/test/modules/test_dsa/expected/test_dsa.out Auto-merging src/backend/utils/mmgr/dsa.c CONFLICT (content): Merge conflict in src/backend/utils/mmgr/dsa.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 Fix DSA pagemap undersizing in make_new_segment. 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". Unstaged changes after reset: M src/backend/utils/mmgr/dsa.c M src/test/modules/test_dsa/expected/test_dsa.out M src/test/modules/test_dsa/sql/test_dsa.sql M src/test/modules/test_dsa/test_dsa--1.0.sql M src/test/modules/test_dsa/test_dsa.c === using patch(1) to apply patch ./v4-0001-Fix-DSA-pagemap-undersizing-in-make_new_segment.patch === patching file src/backend/utils/mmgr/dsa.c Hunk #1 succeeded at 2072 with fuzz 2 (offset -124 lines). Hunk #2 FAILED at 2208. 1 out of 2 hunks FAILED -- saving rejects to file src/backend/utils/mmgr/dsa.c.rej patching file src/test/modules/test_dsa/expected/test_dsa.out Hunk #1 succeeded at 27 (offset 16 lines). patching file src/test/modules/test_dsa/sql/test_dsa.sql Hunk #1 FAILED at 2. 1 out of 1 hunk FAILED -- saving rejects to file src/test/modules/test_dsa/sql/test_dsa.sql.rej patching file src/test/modules/test_dsa/test_dsa--1.0.sql Hunk #1 succeeded at 14 with fuzz 1 (offset 4 lines). patching file src/test/modules/test_dsa/test_dsa.c Hunk #1 FAILED at 16. Hunk #2 succeeded at 160 (offset 40 lines). 1 out of 2 hunks FAILED -- saving rejects to file src/test/modules/test_dsa/test_dsa.c.rej Unstaged changes after reset: M src/backend/utils/mmgr/dsa.c M src/test/modules/test_dsa/expected/test_dsa.out M src/test/modules/test_dsa/test_dsa--1.0.sql M src/test/modules/test_dsa/test_dsa.c Removing src/backend/utils/mmgr/dsa.c.rej Removing src/test/modules/test_dsa/sql/test_dsa.sql.rej Removing src/test/modules/test_dsa/test_dsa.c.rej === using 'git apply' to apply patch ./v4-0001-Fix-DSA-pagemap-undersizing-in-make_new_segment.patch === Applied patch to 'src/backend/utils/mmgr/dsa.c' with conflicts. Applied patch to 'src/test/modules/test_dsa/expected/test_dsa.out' with conflicts. Applied patch to 'src/test/modules/test_dsa/sql/test_dsa.sql' with conflicts. Applied patch to 'src/test/modules/test_dsa/test_dsa--1.0.sql' with conflicts. Applied patch to 'src/test/modules/test_dsa/test_dsa.c' with conflicts. U src/backend/utils/mmgr/dsa.c U src/test/modules/test_dsa/expected/test_dsa.out U src/test/modules/test_dsa/sql/test_dsa.sql U src/test/modules/test_dsa/test_dsa--1.0.sql U src/test/modules/test_dsa/test_dsa.c diff --cc src/backend/utils/mmgr/dsa.c index 4b4f1e1965b,222fa86d83d..00000000000 --- a/src/backend/utils/mmgr/dsa.c +++ b/src/backend/utils/mmgr/dsa.c @@@ -2196,7 -2196,7 +2196,11 @@@ make_new_segment(dsa_area *area, size_ /* See if that is enough... */ if (requested_pages > usable_pages) { ++<<<<<<< ours + size_t total_requested_pages PG_USED_FOR_ASSERTS_ONLY; ++======= + size_t total_pages; ++>>>>>>> theirs /* * We'll make an odd-sized segment, working forward from the requested @@@ -2212,13 -2212,6 +2216,16 @@@ * We must also account for pagemap entries needed to cover the * metadata pages themselves. The pagemap must track all pages in the * segment, including the pages occupied by metadata. ++<<<<<<< ours + * + * This formula uses integer ceiling division to compute the exact + * number of additional entries needed. The divisor (FPM_PAGE_SIZE - + * sizeof(dsa_pointer)) accounts for the fact that each metadata page + * consumes one pagemap entry of sizeof(dsa_pointer) bytes, leaving + * only (FPM_PAGE_SIZE - sizeof(dsa_pointer)) net bytes per metadata + * page. ++======= ++>>>>>>> theirs */ metadata_bytes += ((metadata_bytes + (FPM_PAGE_SIZE - sizeof(dsa_pointer)) - 1) / @@@ -2229,16 -2222,14 +2236,27 @@@ if (metadata_bytes % FPM_PAGE_SIZE != 0) metadata_bytes += FPM_PAGE_SIZE - (metadata_bytes % FPM_PAGE_SIZE); total_size = metadata_bytes + usable_pages * FPM_PAGE_SIZE; ++<<<<<<< ours + total_requested_pages = total_size / FPM_PAGE_SIZE; + + /* + * Verify that we allocated enough pagemap entries for metadata and + * usable pages. This reverse-engineers the new calculation of + * "metadata_bytes" done based on the new "requested_pages" for an + * odd-sized segment. + */ + Assert((metadata_bytes - MAXALIGN(sizeof(dsa_segment_header)) - + MAXALIGN(sizeof(FreePageManager))) / sizeof(dsa_pointer) >= total_requested_pages); ++======= + total_pages = total_size / FPM_PAGE_SIZE; + + /* + * Verify we allocated enough pagemap entries for metadata and usable + * pages + */ + Assert((metadata_bytes - MAXALIGN(sizeof(dsa_segment_header)) - + MAXALIGN(sizeof(FreePageManager))) / sizeof(dsa_pointer) >= total_pages); ++>>>>>>> theirs /* Is that too large for dsa_pointer's addressing scheme? */ if (total_size > DSA_MAX_SEGMENT_SIZE) diff --cc src/test/modules/test_dsa/expected/test_dsa.out index 4b53a7de4a4,2fd10fb349c..00000000000 --- a/src/test/modules/test_dsa/expected/test_dsa.out +++ b/src/test/modules/test_dsa/expected/test_dsa.out @@@ -11,17 -11,11 +11,25 @@@ SELECT test_dsa_resowners() (1 row) ++<<<<<<< ours +-- Test allocations across a pre-defined range of pages. This covers enough +-- range to check for the case of odd-sized segments, without making the test +-- too slow. +SELECT test_dsa_allocate(1001, 2000, 100); + test_dsa_allocate +------------------- + +(1 row) + +-- Larger size with odd-sized segment. +SELECT test_dsa_allocate(6501, 6600, 100); ++======= + -- + -- Test up to 10000 pages skipping 100 pages to cover a wide range of + -- segment layouts without making the test too slow. + -- + SELECT test_dsa_allocate(10000, 100); ++>>>>>>> theirs test_dsa_allocate ------------------- diff --cc src/test/modules/test_dsa/sql/test_dsa.sql index 99b4a60dd14,6b10fe14ba6..00000000000 --- a/src/test/modules/test_dsa/sql/test_dsa.sql +++ b/src/test/modules/test_dsa/sql/test_dsa.sql @@@ -2,10 -2,8 +2,18 @@@ CREATE EXTENSION test_dsa SELECT test_dsa_basic(); SELECT test_dsa_resowners(); ++<<<<<<< ours + +-- Test allocations across a pre-defined range of pages. This covers enough +-- range to check for the case of odd-sized segments, without making the test +-- too slow. +SELECT test_dsa_allocate(1001, 2000, 100); +-- Larger size with odd-sized segment. +SELECT test_dsa_allocate(6501, 6600, 100); ++======= + -- + -- Test up to 10000 pages skipping 100 pages to cover a wide range of + -- segment layouts without making the test too slow. + -- -SELECT test_dsa_allocate(10000, 100); ++SELECT test_dsa_allocate(10000, 100); ++>>>>>>> theirs diff --cc src/test/modules/test_dsa/test_dsa--1.0.sql index 3ee2e44cc00,70baf27123a..00000000000 --- a/src/test/modules/test_dsa/test_dsa--1.0.sql +++ b/src/test/modules/test_dsa/test_dsa--1.0.sql @@@ -11,6 -11,6 +11,10 @@@ CREATE FUNCTION test_dsa_resowners( RETURNS pg_catalog.void AS 'MODULE_PATHNAME' LANGUAGE C; ++<<<<<<< ours +CREATE FUNCTION test_dsa_allocate(int, int, int) ++======= + CREATE FUNCTION test_dsa_allocate(int, int) ++>>>>>>> theirs RETURNS pg_catalog.void AS 'MODULE_PATHNAME' LANGUAGE C; diff --cc src/test/modules/test_dsa/test_dsa.c index edcab105de6,a72871ea0d3..00000000000 --- a/src/test/modules/test_dsa/test_dsa.c +++ b/src/test/modules/test_dsa/test_dsa.c @@@ -134,22 -134,18 +134,34 @@@ PG_FUNCTION_INFO_V1(test_dsa_allocate) Datum test_dsa_allocate(PG_FUNCTION_ARGS) { ++<<<<<<< ours + int start_num_pages = PG_GETARG_INT32(0); + int end_num_pages = PG_GETARG_INT32(1); + int step = PG_GETARG_INT32(2); ++======= + int num_pages = PG_GETARG_INT32(0); + int step = PG_GETARG_INT32(1); ++>>>>>>> theirs size_t usable_pages; int *tranche_id; bool found; dsa_area *a; dsa_pointer dp; ++<<<<<<< ours + if (start_num_pages > end_num_pages) + elog(ERROR, "incorrect start and end parameters"); + + tranche_id = GetNamedDSMSegment("test_dsa", sizeof(int), + init_tranche, &found, NULL); + + for (usable_pages = start_num_pages; usable_pages < end_num_pages; usable_pages += step) ++======= + tranche_id = GetNamedDSMSegment("test_dsa", sizeof(int), + init_tranche, &found, NULL); + + for (usable_pages = 1; usable_pages < num_pages; usable_pages += step) ++>>>>>>> theirs { a = dsa_create(*tranche_id); dp = dsa_allocate(a, usable_pages * FPM_PAGE_SIZE);