=== Applying patches on top of PostgreSQL commit ID 66ad764c8d517f59577d41ac3dad786729c9e10e === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Tue Apr 14 18:43:26 UTC 2026 On branch cf/5124 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-Fix-pg_control-corruption-in-EXEC_BACKEND-startup.patch === Applying: Fix pg_control corruption in EXEC_BACKEND startup. Using index info to reconstruct a base tree... M src/backend/access/transam/xlog.c M src/backend/postmaster/launch_backend.c M src/include/access/xlog.h Falling back to patching base and 3-way merge... Auto-merging src/include/access/xlog.h Auto-merging src/backend/postmaster/launch_backend.c CONFLICT (content): Merge conflict in src/backend/postmaster/launch_backend.c Auto-merging src/backend/access/transam/xlog.c CONFLICT (content): Merge conflict in src/backend/access/transam/xlog.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 pg_control corruption in EXEC_BACKEND startup. 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-Fix-pg_control-corruption-in-EXEC_BACKEND-startup.patch === patching file src/backend/access/transam/xlog.c Hunk #1 succeeded at 577 with fuzz 2 (offset 2 lines). Hunk #2 succeeded at 729 (offset 33 lines). Hunk #3 succeeded at 4414 (offset 24 lines). Hunk #4 succeeded at 4447 (offset 24 lines). Hunk #5 FAILED at 4953. Hunk #6 FAILED at 5073. 2 out of 6 hunks FAILED -- saving rejects to file src/backend/access/transam/xlog.c.rej patching file src/backend/postmaster/launch_backend.c Hunk #2 succeeded at 135 with fuzz 2 (offset -1 lines). Hunk #3 FAILED at 670. Hunk #4 succeeded at 766 with fuzz 2 (offset 3 lines). Hunk #5 succeeded at 1042 (offset 3 lines). 1 out of 5 hunks FAILED -- saving rejects to file src/backend/postmaster/launch_backend.c.rej patching file src/include/access/xlog.h Hunk #1 succeeded at 209 (offset 1 line). Hunk #2 succeeded at 263 (offset 12 lines). Unstaged changes after reset: M src/backend/access/transam/xlog.c M src/backend/postmaster/launch_backend.c M src/include/access/xlog.h Removing src/backend/access/transam/xlog.c.rej Removing src/backend/postmaster/launch_backend.c.rej === using 'git apply' to apply patch ./v2-0001-Fix-pg_control-corruption-in-EXEC_BACKEND-startup.patch === Applied patch to 'src/backend/access/transam/xlog.c' with conflicts. Applied patch to 'src/backend/postmaster/launch_backend.c' with conflicts. Applied patch to 'src/include/access/xlog.h' cleanly. U src/backend/access/transam/xlog.c U src/backend/postmaster/launch_backend.c diff --cc src/backend/access/transam/xlog.c index f85b5286086,e52517eb9c1..00000000000 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@@ -580,18 -573,11 +580,24 @@@ static WALInsertLockPadded *WALInsertLo /* * We maintain an image of pg_control in shared memory. */ +static ControlFileData *LocalControlFile = NULL; static ControlFileData *ControlFile = NULL; ++<<<<<<< ours +static void XLOGShmemRequest(void *arg); +static void XLOGShmemInit(void *arg); +static void XLOGShmemAttach(void *arg); + +const ShmemCallbacks XLOGShmemCallbacks = { + .request_fn = XLOGShmemRequest, + .init_fn = XLOGShmemInit, + .attach_fn = XLOGShmemAttach, +}; ++======= + #ifdef EXEC_BACKEND + static ControlFileData *ProtoControlFile = NULL; + #endif ++>>>>>>> theirs /* * Calculate the amount of space left on the page after 'endptr'. Beware @@@ -5269,12 -4951,35 +5283,40 @@@ voi LocalProcessControlFile(bool reset) { Assert(reset || ControlFile == NULL); - ControlFile = palloc_object(ControlFileData); + LocalControlFile = palloc_object(ControlFileData); + ControlFile = LocalControlFile; ReadControlFile(); ++<<<<<<< ours + SetLocalDataChecksumState(ControlFile->data_checksum_version); ++======= + + #ifdef EXEC_BACKEND + /* We need to be able to give this to subprocesses. */ + ProtoControlFile = ControlFile; + #endif + } + + #ifdef EXEC_BACKEND + void + ExportProtoControlFile(ControlFileData *copy) + { + *copy = *ProtoControlFile; } + /* + * Like LocalProcessControlFile(), but used early in EXEC_BACKEND children's + * startup. This receives the same file that the postmaster first read. + */ + void + ImportProtoControlFile(const ControlFileData *copy) + { + ControlFile = palloc(sizeof(ControlFileData)); + *ControlFile = *copy; + ScanControlFile(); ++>>>>>>> theirs + } + #endif + /* * Get the wal_level from the control file. For a standby, this value should be * considered as its active wal_level, because it may be different from what @@@ -5371,11 -5095,15 +5413,21 @@@ XLOGShmemInit(void *arg * Already have read control file locally, unless in bootstrap mode. Move * contents into shared memory. */ - if (localControlFile) + if (LocalControlFile) { ++<<<<<<< ours + memcpy(ControlFile, LocalControlFile, sizeof(ControlFileData)); + pfree(LocalControlFile); + LocalControlFile = NULL; ++======= + memcpy(ControlFile, localControlFile, sizeof(ControlFileData)); + #ifdef EXEC_BACKEND + /* We still hold a reference to give to subprocesses. */ + Assert(ProtoControlFile == localControlFile); + #else + pfree(localControlFile); + #endif ++>>>>>>> theirs } /* diff --cc src/backend/postmaster/launch_backend.c index 8f3cfea880c,e08a405f949..00000000000 --- a/src/backend/postmaster/launch_backend.c +++ b/src/backend/postmaster/launch_backend.c @@@ -130,8 -136,14 +133,16 @@@ typedef struc int MyPMChildSlot; + int32 timing_tsc_frequency_khz; + + /* + * A copy of the ControlFileData from early in Postmaster startup. We + * need to access its contents it at a phase of initialization before we + * are allowed to acquire LWLocks, so we can't just use shared memory or + * read the file from disk. + */ + ControlFileData proto_controlfile; + /* * These are only used by backend processes, but are here because passing * a socket needs some special handling on Windows. 'client_sock' is an @@@ -662,14 -671,6 +673,17 @@@ SubPostmasterMain(int argc, char *argv[ checkDataDir(); /* ++<<<<<<< ours + * (re-)read control file, as it contains config. The postmaster will + * already have read this, but this process doesn't know about that. + */ + LocalProcessControlFile(false); + + RegisterBuiltinShmemCallbacks(); + + /* ++======= ++>>>>>>> theirs * Reload any libraries that were preloaded by the postmaster. Since we * exec'd this process, those libraries didn't come along with us; but we * should load them into all child processes to be consistent with the @@@ -753,7 -757,7 +767,11 @@@ save_backend_variables(BackendParameter param->MaxBackends = MaxBackends; param->num_pmchild_slots = num_pmchild_slots; ++<<<<<<< ours + param->timing_tsc_frequency_khz = timing_tsc_frequency_khz; ++======= + ExportProtoControlFile(¶m->proto_controlfile); ++>>>>>>> theirs #ifdef WIN32 param->PostmasterHandle = PostmasterHandle;