=== Applying patches on top of PostgreSQL commit ID 972c14fb9134fdfd76ea6ebcf98a55a945bbc988 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Apr 15 08:24:28 UTC 2026 On branch cf/6427 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-Create-dedicated-shmem-Autotune-functions.patch === Applying: Create dedicated shmem Autotune functions Using index info to reconstruct a base tree... M src/backend/access/transam/clog.c M src/backend/access/transam/commit_ts.c M src/backend/access/transam/subtrans.c M src/backend/access/transam/xlog.c M src/backend/bootstrap/bootstrap.c M src/backend/postmaster/postmaster.c M src/backend/storage/aio/aio_init.c M src/backend/storage/ipc/ipci.c M src/backend/tcop/postgres.c M src/include/access/clog.h M src/include/access/commit_ts.h M src/include/access/subtrans.h M src/include/access/xlog.h M src/include/storage/aio_subsys.h M src/include/storage/ipc.h Falling back to patching base and 3-way merge... Auto-merging src/include/storage/ipc.h Auto-merging src/include/storage/aio_subsys.h CONFLICT (content): Merge conflict in src/include/storage/aio_subsys.h Auto-merging src/include/access/xlog.h CONFLICT (content): Merge conflict in src/include/access/xlog.h Auto-merging src/include/access/subtrans.h CONFLICT (content): Merge conflict in src/include/access/subtrans.h Auto-merging src/include/access/commit_ts.h CONFLICT (content): Merge conflict in src/include/access/commit_ts.h Auto-merging src/include/access/clog.h CONFLICT (content): Merge conflict in src/include/access/clog.h Auto-merging src/backend/tcop/postgres.c CONFLICT (content): Merge conflict in src/backend/tcop/postgres.c Auto-merging src/backend/storage/ipc/ipci.c Auto-merging src/backend/storage/aio/aio_init.c CONFLICT (content): Merge conflict in src/backend/storage/aio/aio_init.c Auto-merging src/backend/postmaster/postmaster.c CONFLICT (content): Merge conflict in src/backend/postmaster/postmaster.c Auto-merging src/backend/bootstrap/bootstrap.c CONFLICT (content): Merge conflict in src/backend/bootstrap/bootstrap.c Auto-merging src/backend/access/transam/xlog.c CONFLICT (content): Merge conflict in src/backend/access/transam/xlog.c Auto-merging src/backend/access/transam/subtrans.c CONFLICT (content): Merge conflict in src/backend/access/transam/subtrans.c Auto-merging src/backend/access/transam/commit_ts.c CONFLICT (content): Merge conflict in src/backend/access/transam/commit_ts.c Auto-merging src/backend/access/transam/clog.c CONFLICT (content): Merge conflict in src/backend/access/transam/clog.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 Create dedicated shmem Autotune functions 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 ./v2-0001-Create-dedicated-shmem-Autotune-functions.patch === patching file src/backend/access/transam/clog.c Hunk #1 succeeded at 766 (offset 10 lines). Hunk #2 succeeded at 802 (offset 10 lines). Hunk #3 FAILED at 808. 1 out of 3 hunks FAILED -- saving rejects to file src/backend/access/transam/clog.c.rej patching file src/backend/access/transam/commit_ts.c Hunk #1 succeeded at 504 (offset 11 lines). Hunk #2 succeeded at 540 (offset 11 lines). Hunk #3 FAILED at 552. 1 out of 3 hunks FAILED -- saving rejects to file src/backend/access/transam/commit_ts.c.rej patching file src/backend/access/transam/subtrans.c Hunk #1 succeeded at 199 (offset 8 lines). Hunk #2 FAILED at 208. 1 out of 2 hunks FAILED -- saving rejects to file src/backend/access/transam/subtrans.c.rej patching file src/backend/access/transam/xlog.c Hunk #1 succeeded at 5045 (offset 329 lines). Hunk #2 FAILED at 4956. 1 out of 2 hunks FAILED -- saving rejects to file src/backend/access/transam/xlog.c.rej patching file src/backend/bootstrap/bootstrap.c Hunk #1 FAILED at 337. 1 out of 1 hunk FAILED -- saving rejects to file src/backend/bootstrap/bootstrap.c.rej patching file src/backend/postmaster/postmaster.c Hunk #1 succeeded at 968 with fuzz 2 (offset 5 lines). patching file src/backend/storage/aio/aio_init.c Hunk #1 FAILED at 109. Hunk #2 succeeded at 131 with fuzz 2 (offset 11 lines). 1 out of 2 hunks FAILED -- saving rejects to file src/backend/storage/aio/aio_init.c.rej patching file src/backend/storage/ipc/ipci.c Hunk #1 succeeded at 221 (offset -153 lines). patching file src/backend/tcop/postgres.c Hunk #1 succeeded at 4131 with fuzz 2 (offset -2 lines). patching file src/include/access/clog.h Hunk #1 FAILED at 41. 1 out of 1 hunk FAILED -- saving rejects to file src/include/access/clog.h.rej patching file src/include/access/commit_ts.h Hunk #1 FAILED at 28. 1 out of 1 hunk FAILED -- saving rejects to file src/include/access/commit_ts.h.rej patching file src/include/access/subtrans.h Hunk #1 FAILED at 16. 1 out of 1 hunk FAILED -- saving rejects to file src/include/access/subtrans.h.rej patching file src/include/access/xlog.h Hunk #1 FAILED at 245. 1 out of 1 hunk FAILED -- saving rejects to file src/include/access/xlog.h.rej patching file src/include/storage/aio_subsys.h Hunk #1 FAILED at 21. 1 out of 1 hunk FAILED -- saving rejects to file src/include/storage/aio_subsys.h.rej patching file src/include/storage/ipc.h Hunk #1 succeeded at 84 (offset 1 line). Unstaged changes after reset: M src/backend/access/transam/clog.c M src/backend/access/transam/commit_ts.c M src/backend/access/transam/subtrans.c M src/backend/access/transam/xlog.c M src/backend/postmaster/postmaster.c M src/backend/storage/aio/aio_init.c M src/backend/storage/ipc/ipci.c M src/backend/tcop/postgres.c M src/include/storage/ipc.h Removing src/backend/access/transam/clog.c.rej Removing src/backend/access/transam/commit_ts.c.rej Removing src/backend/access/transam/subtrans.c.rej Removing src/backend/access/transam/xlog.c.rej Removing src/backend/bootstrap/bootstrap.c.rej Removing src/backend/storage/aio/aio_init.c.rej Removing src/include/access/clog.h.rej Removing src/include/access/commit_ts.h.rej Removing src/include/access/subtrans.h.rej Removing src/include/access/xlog.h.rej Removing src/include/storage/aio_subsys.h.rej === using 'git apply' to apply patch ./v2-0001-Create-dedicated-shmem-Autotune-functions.patch === Applied patch to 'src/backend/access/transam/clog.c' with conflicts. Applied patch to 'src/backend/access/transam/commit_ts.c' with conflicts. Applied patch to 'src/backend/access/transam/subtrans.c' with conflicts. Applied patch to 'src/backend/access/transam/xlog.c' with conflicts. Applied patch to 'src/backend/bootstrap/bootstrap.c' with conflicts. Applied patch to 'src/backend/postmaster/postmaster.c' with conflicts. Applied patch to 'src/backend/storage/aio/aio_init.c' with conflicts. Applied patch to 'src/backend/storage/ipc/ipci.c' cleanly. Applied patch to 'src/backend/tcop/postgres.c' with conflicts. Applied patch to 'src/include/access/clog.h' with conflicts. Applied patch to 'src/include/access/commit_ts.h' with conflicts. Applied patch to 'src/include/access/subtrans.h' with conflicts. Applied patch to 'src/include/access/xlog.h' with conflicts. Applied patch to 'src/include/storage/aio_subsys.h' with conflicts. Applied patch to 'src/include/storage/ipc.h' cleanly. U src/backend/access/transam/clog.c U src/backend/access/transam/commit_ts.c U src/backend/access/transam/subtrans.c U src/backend/access/transam/xlog.c U src/backend/bootstrap/bootstrap.c U src/backend/postmaster/postmaster.c U src/backend/storage/aio/aio_init.c U src/backend/tcop/postgres.c U src/include/access/clog.h U src/include/access/commit_ts.h U src/include/access/subtrans.h U src/include/access/xlog.h U src/include/storage/aio_subsys.h diff --cc src/backend/access/transam/clog.c index 75012d4b8f0,2925ecbece4..00000000000 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@@ -784,51 -797,21 +807,58 @@@ CLOGShmemBuffers(void } /* - * Initialization of shared memory for CLOG + * Register shared memory for CLOG */ -Size -CLOGShmemSize(void) +static void +CLOGShmemRequest(void *arg) { - return SimpleLruShmemSize(CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE); ++<<<<<<< ours + /* If auto-tuning is requested, now is the time to do it */ + if (transaction_buffers == 0) + { + char buf[32]; + + snprintf(buf, sizeof(buf), "%d", CLOGShmemBuffers()); + SetConfigOption("transaction_buffers", buf, PGC_POSTMASTER, + PGC_S_DYNAMIC_DEFAULT); + + /* + * We prefer to report this value's source as PGC_S_DYNAMIC_DEFAULT. + * However, if the DBA explicitly set transaction_buffers = 0 in the + * config file, then PGC_S_DYNAMIC_DEFAULT will fail to override that + * and we must force the matter with PGC_S_OVERRIDE. + */ + if (transaction_buffers == 0) /* failed to apply it? */ + SetConfigOption("transaction_buffers", buf, PGC_POSTMASTER, + PGC_S_OVERRIDE); + } + Assert(transaction_buffers != 0); + SimpleLruRequest(.desc = &XactSlruDesc, + .name = "transaction", + .Dir = "pg_xact", + .long_segment_names = false, + + .nslots = CLOGShmemBuffers(), + .nlsns = CLOG_LSNS_PER_PAGE, + + .sync_handler = SYNC_HANDLER_CLOG, + .PagePrecedes = CLOGPagePrecedes, + .errdetail_for_io_error = clog_errdetail_for_io_error, + + .buffer_tranche_id = LWTRANCHE_XACT_BUFFER, + .bank_tranche_id = LWTRANCHE_XACT_SLRU, + ); } -void -CLOGShmemInit(void) +static void +CLOGShmemInit(void *arg) { ++======= + XactCtl->PagePrecedes = CLOGPagePrecedes; + SimpleLruInit(XactCtl, "transaction", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE, + "pg_xact", LWTRANCHE_XACT_BUFFER, + LWTRANCHE_XACT_SLRU, SYNC_HANDLER_CLOG, false); ++>>>>>>> theirs SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE); } diff --cc src/backend/access/transam/commit_ts.c index 2625cbf93bf,f76b43bf25a..00000000000 --- a/src/backend/access/transam/commit_ts.c +++ b/src/backend/access/transam/commit_ts.c @@@ -522,62 -534,47 +545,74 @@@ CommitTsShmemBuffers(void } /* - * Shared memory sizing for CommitTs + * Register CommitTs shared memory needs at system startup (postmaster start + * or standalone backend) */ -Size -CommitTsShmemSize(void) +static void +CommitTsShmemRequest(void *arg) { - return SimpleLruShmemSize(CommitTsShmemBuffers(), 0) + - sizeof(CommitTimestampShared); -} ++<<<<<<< ours + /* If auto-tuning is requested, now is the time to do it */ + if (commit_timestamp_buffers == 0) + { + char buf[32]; -/* - * Initialize CommitTs at system startup (postmaster start or standalone - * backend) - */ -void -CommitTsShmemInit(void) -{ + snprintf(buf, sizeof(buf), "%d", CommitTsShmemBuffers()); + SetConfigOption("commit_timestamp_buffers", buf, PGC_POSTMASTER, + PGC_S_DYNAMIC_DEFAULT); + + /* + * We prefer to report this value's source as PGC_S_DYNAMIC_DEFAULT. + * However, if the DBA explicitly set commit_timestamp_buffers = 0 in + * the config file, then PGC_S_DYNAMIC_DEFAULT will fail to override + * that and we must force the matter with PGC_S_OVERRIDE. + */ + if (commit_timestamp_buffers == 0) /* failed to apply it? */ + SetConfigOption("commit_timestamp_buffers", buf, PGC_POSTMASTER, + PGC_S_OVERRIDE); + } + Assert(commit_timestamp_buffers != 0); + SimpleLruRequest(.desc = &CommitTsSlruDesc, + .name = "commit_timestamp", + .Dir = "pg_commit_ts", + .long_segment_names = false, + + .nslots = CommitTsShmemBuffers(), ++======= + bool found; + + CommitTsCtl->PagePrecedes = CommitTsPagePrecedes; + SimpleLruInit(CommitTsCtl, "commit_timestamp", CommitTsShmemBuffers(), 0, + "pg_commit_ts", LWTRANCHE_COMMITTS_BUFFER, + LWTRANCHE_COMMITTS_SLRU, + SYNC_HANDLER_COMMIT_TS, + false); + SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE); ++>>>>>>> theirs - commitTsShared = ShmemInitStruct("CommitTs shared", - sizeof(CommitTimestampShared), - &found); + .PagePrecedes = CommitTsPagePrecedes, + .errdetail_for_io_error = commit_ts_errdetail_for_io_error, - if (!IsUnderPostmaster) - { - Assert(!found); + .sync_handler = SYNC_HANDLER_COMMIT_TS, + .buffer_tranche_id = LWTRANCHE_COMMITTS_BUFFER, + .bank_tranche_id = LWTRANCHE_COMMITTS_SLRU, + ); - commitTsShared->xidLastCommit = InvalidTransactionId; - TIMESTAMP_NOBEGIN(commitTsShared->dataLastCommit.time); - commitTsShared->dataLastCommit.nodeid = InvalidRepOriginId; - commitTsShared->commitTsActive = false; - } - else - Assert(found); + ShmemRequestStruct(.name = "CommitTs shared", + .size = sizeof(CommitTimestampShared), + .ptr = (void **) &commitTsShared, + ); +} + +static void +CommitTsShmemInit(void *arg) +{ + commitTsShared->xidLastCommit = InvalidTransactionId; + TIMESTAMP_NOBEGIN(commitTsShared->dataLastCommit.time); + commitTsShared->dataLastCommit.nodeid = InvalidReplOriginId; + commitTsShared->commitTsActive = false; + + SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE); } /* diff --cc src/backend/access/transam/subtrans.c index b79e648b899,32433b0333f..00000000000 --- a/src/backend/access/transam/subtrans.c +++ b/src/backend/access/transam/subtrans.c @@@ -214,54 -199,52 +207,81 @@@ SUBTRANSShmemBuffers(void return Min(Max(16, subtransaction_buffers), SLRU_MAX_ALLOWED_BUFFERS); } + + /* - * Initialization of shared memory for SUBTRANS + * Register shared memory for SUBTRANS */ ++<<<<<<< ours +static void +SUBTRANSShmemRequest(void *arg) ++======= + Size + SUBTRANSShmemSize(void) { - /* If auto-tuning is requested, now is the time to do it */ - if (subtransaction_buffers == 0) - { - char buf[32]; + return SimpleLruShmemSize(SUBTRANSShmemBuffers(), 0); + } - snprintf(buf, sizeof(buf), "%d", SUBTRANSShmemBuffers()); - SetConfigOption("subtransaction_buffers", buf, PGC_POSTMASTER, - PGC_S_DYNAMIC_DEFAULT); + /* + * Auto-tune subtransaction_buffers based on shared_buffers + * + * If asked to autotune, use 2MB for every 1GB of shared buffers, up to 8MB. + * Otherwise just cap the configured amount to be between 16 and the maximum + * allowed. + */ + void + SUBTRANSAutotune(void) ++>>>>>>> theirs + { + char buf[32]; - /* - * We prefer to report this value's source as PGC_S_DYNAMIC_DEFAULT. - * However, if the DBA explicitly set subtransaction_buffers = 0 in - * the config file, then PGC_S_DYNAMIC_DEFAULT will fail to override - * that and we must force the matter with PGC_S_OVERRIDE. - */ - if (subtransaction_buffers == 0) /* failed to apply it? */ - SetConfigOption("subtransaction_buffers", buf, PGC_POSTMASTER, - PGC_S_OVERRIDE); - } - Assert(subtransaction_buffers != 0); + if (subtransaction_buffers != 0) + return; + + snprintf(buf, sizeof(buf), "%d", SimpleLruAutotuneBuffers(512, 1024)); + SetConfigOption("subtransaction_buffers", buf, PGC_POSTMASTER, + PGC_S_DYNAMIC_DEFAULT); ++<<<<<<< ours + SimpleLruRequest(.desc = &SubTransSlruDesc, + .name = "subtransaction", + .Dir = "pg_subtrans", + .long_segment_names = false, + + .nslots = SUBTRANSShmemBuffers(), + + .sync_handler = SYNC_HANDLER_NONE, + .PagePrecedes = SubTransPagePrecedes, + .errdetail_for_io_error = subtrans_errdetail_for_io_error, + + .buffer_tranche_id = LWTRANCHE_SUBTRANS_BUFFER, + .bank_tranche_id = LWTRANCHE_SUBTRANS_SLRU, + ); +} + +static void +SUBTRANSShmemInit(void *arg) +{ ++======= + /* + * We prefer to report this value's source as PGC_S_DYNAMIC_DEFAULT. + * However, if the DBA explicitly set subtransaction_buffers = 0 in the + * config file, then PGC_S_DYNAMIC_DEFAULT will fail to override that and + * we must force the matter with PGC_S_OVERRIDE. + */ + if (subtransaction_buffers == 0) /* failed to apply it? */ + SetConfigOption("subtransaction_buffers", buf, PGC_POSTMASTER, + PGC_S_OVERRIDE); + } + + void + SUBTRANSShmemInit(void) + { + SubTransCtl->PagePrecedes = SubTransPagePrecedes; + SimpleLruInit(SubTransCtl, "subtransaction", SUBTRANSShmemBuffers(), 0, + "pg_subtrans", LWTRANCHE_SUBTRANS_BUFFER, + LWTRANCHE_SUBTRANS_SLRU, SYNC_HANDLER_NONE, false); ++>>>>>>> theirs SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE); } diff --cc src/backend/access/transam/xlog.c index f85b5286086,fee808dd8d7..00000000000 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@@ -5287,19 -4956,23 +5287,30 @@@ GetActiveWalLevelOnStandby(void } /* ++<<<<<<< ours + * Register shared memory for XLOG. + */ +static void +XLOGShmemRequest(void *arg) ++======= + * Auto-tune wal_buffers value + * + * If the value of wal_buffers is -1, use the preferred auto-tune value. + */ + void + XLOGAutotune(void) ++>>>>>>> theirs { - Size size; + char buf[32]; + + if (XLOGbuffers != -1) + return; + + snprintf(buf, sizeof(buf), "%d", XLOGChooseNumBuffers()); + SetConfigOption("wal_buffers", buf, PGC_POSTMASTER, + PGC_S_DYNAMIC_DEFAULT); /* - * If the value of wal_buffers is -1, use the preferred auto-tune value. - * This isn't an amazingly clean place to do this, but we must wait till - * NBuffers has received its final value, and must do it before using the - * value of XLOGbuffers to do anything important. - * * We prefer to report this value's source as PGC_S_DYNAMIC_DEFAULT. * However, if the DBA explicitly set wal_buffers = -1 in the config file, * then PGC_S_DYNAMIC_DEFAULT will fail to override that and we must force diff --cc src/backend/bootstrap/bootstrap.c index a4af7bf8fad,4bbedb44b53..00000000000 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@@ -376,7 -337,11 +376,15 @@@ BootstrapModeMain(int argc, char *argv[ InitializeFastPathLocks(); ++<<<<<<< ours + ShmemCallRequestCallbacks(); ++======= + /* + * Give the chance for subsystems to auto-tune their values. + */ + AutotuneShmem(); + ++>>>>>>> theirs CreateSharedMemoryAndSemaphores(); /* diff --cc src/backend/postmaster/postmaster.c index 6e0f41d2661,f4e60274924..00000000000 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@@ -969,10 -964,9 +969,16 @@@ PostmasterMain(int argc, char *argv[] process_shmem_requests(); /* ++<<<<<<< ours + * Ask all subsystems, including preloaded libraries, to register their + * shared memory needs. + */ + ShmemCallRequestCallbacks(); ++======= + * Give the chance for subsystems to auto-tune their values. + */ + AutotuneShmem(); ++>>>>>>> theirs /* * Now that loadable modules have had their chance to request additional diff --cc src/backend/storage/aio/aio_init.c index da30d792a88,ec8d61dfb9c..00000000000 --- a/src/backend/storage/aio/aio_init.c +++ b/src/backend/storage/aio/aio_init.c @@@ -117,67 -109,51 +117,80 @@@ AioChooseMaxConcurrency(void return Min(max_proportional_pins, 64); } ++<<<<<<< ours +/* + * Register AIO subsystem's shared memory needs. + */ +static void +AioShmemRequest(void *arg) +{ ++======= + void + AioAutotune(void) + { + char buf[32]; + + if (io_max_concurrency != -1) + return; + + snprintf(buf, sizeof(buf), "%d", AioChooseMaxConcurrency()); + SetConfigOption("io_max_concurrency", buf, PGC_POSTMASTER, + PGC_S_DYNAMIC_DEFAULT); + ++>>>>>>> theirs /* + * Resolve io_max_concurrency if not already done + * * We prefer to report this value's source as PGC_S_DYNAMIC_DEFAULT. * However, if the DBA explicitly set io_max_concurrency = -1 in the * config file, then PGC_S_DYNAMIC_DEFAULT will fail to override that and * we must force the matter with PGC_S_OVERRIDE. */ - if (io_max_concurrency == -1) - { - char buf[32]; - - snprintf(buf, sizeof(buf), "%d", AioChooseMaxConcurrency()); + if (io_max_concurrency == -1) /* failed to apply it? */ SetConfigOption("io_max_concurrency", buf, PGC_POSTMASTER, - PGC_S_DYNAMIC_DEFAULT); - if (io_max_concurrency == -1) /* failed to apply it? */ - SetConfigOption("io_max_concurrency", buf, PGC_POSTMASTER, - PGC_S_OVERRIDE); - } + PGC_S_OVERRIDE); + } + + Size + AioShmemSize(void) + { + Size sz = 0; - sz = add_size(sz, AioCtlShmemSize()); - sz = add_size(sz, AioBackendShmemSize()); - sz = add_size(sz, AioHandleShmemSize()); - sz = add_size(sz, AioHandleIOVShmemSize()); - sz = add_size(sz, AioHandleDataShmemSize()); - - /* Reserve space for method specific resources. */ - if (pgaio_method_ops->shmem_size) - sz = add_size(sz, pgaio_method_ops->shmem_size()); - - return sz; + ShmemRequestStruct(.name = "AioCtl", + .size = sizeof(PgAioCtl), + .ptr = (void **) &pgaio_ctl, + ); + + ShmemRequestStruct(.name = "AioBackend", + .size = AioBackendShmemSize(), + .ptr = (void **) &AioBackendShmemPtr, + ); + + ShmemRequestStruct(.name = "AioHandle", + .size = AioHandleShmemSize(), + .ptr = (void **) &AioHandleShmemPtr, + ); + + ShmemRequestStruct(.name = "AioHandleIOV", + .size = AioHandleIOVShmemSize(), + .ptr = (void **) &AioHandleIOVShmemPtr, + ); + + ShmemRequestStruct(.name = "AioHandleData", + .size = AioHandleDataShmemSize(), + .ptr = (void **) &AioHandleDataShmemPtr, + ); + + if (pgaio_method_ops->shmem_callbacks.request_fn) + pgaio_method_ops->shmem_callbacks.request_fn(pgaio_method_ops->shmem_callbacks.opaque_arg); } -void -AioShmemInit(void) +/* + * Initialize AIO shared memory during postmaster startup. + */ +static void +AioShmemInit(void *arg) { - bool found; uint32 io_handle_off = 0; uint32 iovec_off = 0; uint32 per_backend_iovecs = io_max_concurrency * io_max_combine_limit; diff --cc src/backend/tcop/postgres.c index aeaf1c6db8f,0e8744ed37c..00000000000 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@@ -4197,10 -4134,9 +4197,16 @@@ PostgresSingleUserMain(int argc, char * process_shmem_requests(); /* ++<<<<<<< ours + * Before computing the total size needed, give all subsystems, including + * add-ins, a chance to chance to adjust their requested shmem sizes. + */ + ShmemCallRequestCallbacks(); ++======= + * Give the chance for subsystems to auto-tune their values. + */ + AutotuneShmem(); ++>>>>>>> theirs /* * Now that loadable modules have had their chance to request additional diff --cc src/include/access/clog.h index 7894998c763,b2a9c0ac255..00000000000 --- a/src/include/access/clog.h +++ b/src/include/access/clog.h @@@ -40,6 -40,9 +40,12 @@@ extern void TransactionIdSetTreeStatus( TransactionId *subxids, XidStatus status, XLogRecPtr lsn); extern XidStatus TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn); ++<<<<<<< ours ++======= + extern Size CLOGShmemSize(void); + extern void CLOGAutotune(void); + extern void CLOGShmemInit(void); ++>>>>>>> theirs extern void BootStrapCLOG(void); extern void StartupCLOG(void); extern void TrimCLOG(void); diff --cc src/include/access/commit_ts.h index 825ccda90ed,80b35d2e0dc..00000000000 --- a/src/include/access/commit_ts.h +++ b/src/include/access/commit_ts.h @@@ -21,12 -21,15 +21,18 @@@ extern PGDLLIMPORT bool track_commit_ti extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids, TransactionId *subxids, TimestampTz timestamp, - RepOriginId nodeid); + ReplOriginId nodeid); extern bool TransactionIdGetCommitTsData(TransactionId xid, - TimestampTz *ts, RepOriginId *nodeid); + TimestampTz *ts, ReplOriginId *nodeid); extern TransactionId GetLatestCommitTsData(TimestampTz *ts, - RepOriginId *nodeid); + ReplOriginId *nodeid); ++<<<<<<< ours ++======= + extern Size CommitTsShmemSize(void); + extern void CommitTsAutotune(void); + extern void CommitTsShmemInit(void); ++>>>>>>> theirs extern void BootStrapCommitTs(void); extern void StartupCommitTs(void); extern void CommitTsParameterChange(bool newvalue, bool oldvalue); diff --cc src/include/access/subtrans.h index d986cd9e802,3772af83f68..00000000000 --- a/src/include/access/subtrans.h +++ b/src/include/access/subtrans.h @@@ -15,6 -15,9 +15,12 @@@ extern void SubTransSetParent(Transacti extern TransactionId SubTransGetParent(TransactionId xid); extern TransactionId SubTransGetTopmostTransaction(TransactionId xid); ++<<<<<<< ours ++======= + extern Size SUBTRANSShmemSize(void); + extern void SUBTRANSAutotune(void); + extern void SUBTRANSShmemInit(void); ++>>>>>>> theirs extern void BootStrapSUBTRANS(void); extern void StartupSUBTRANS(TransactionId oldestActiveXID); extern void CheckPointSUBTRANS(void); diff --cc src/include/access/xlog.h index 437b4f32349,21741eb9254..00000000000 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@@ -247,18 -241,12 +247,24 @@@ extern XLogRecPtr GetXLogWriteRecPtr(vo extern uint64 GetSystemIdentifier(void); extern char *GetMockAuthenticationNonce(void); -extern bool DataChecksumsEnabled(void); +extern bool DataChecksumsNeedWrite(void); +extern bool DataChecksumsNeedVerify(void); +extern bool DataChecksumsInProgressOn(void); +extern void SetDataChecksumsOnInProgress(void); +extern void SetDataChecksumsOn(void); +extern void SetDataChecksumsOff(void); +extern const char *show_data_checksums(void); +extern const char *get_checksum_state_string(uint32 state); +extern void InitLocalDataChecksumState(void); +extern void SetLocalDataChecksumState(uint32 data_checksum_version); extern bool GetDefaultCharSignedness(void); extern XLogRecPtr GetFakeLSNForUnloggedRel(void); ++<<<<<<< ours ++======= + extern Size XLOGShmemSize(void); + extern void XLOGAutotune(void); + extern void XLOGShmemInit(void); ++>>>>>>> theirs extern void BootStrapXLOG(uint32 data_checksum_version); extern void InitializeWalConsistencyChecking(void); extern void LocalProcessControlFile(bool reset); diff --cc src/include/storage/aio_subsys.h index b0e5c337228,1d305d75000..00000000000 --- a/src/include/storage/aio_subsys.h +++ b/src/include/storage/aio_subsys.h @@@ -20,6 -20,10 +20,13 @@@ /* aio_init.c */ ++<<<<<<< ours ++======= + extern Size AioShmemSize(void); + extern void AioAutotune(void); + extern void AioShmemInit(void); + ++>>>>>>> theirs extern void pgaio_init_backend(void);