=== Applying patches on top of PostgreSQL commit ID a7f8cd811d65d1a51be87bdb890d7ebf7d49aa45 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Mon Oct 5 03:57:39 UTC 2026 On branch cf/6988 nothing to commit, working tree clean === using 'git am' to apply patch ./v3-0001-ecpg-Fix-auto_mem-cleanup-on-thread-exit.patch === Applying: ecpg: Fix auto_mem cleanup on thread exit. === using 'git am' to apply patch ./v3-0002-port-Provide-pg_threads.h-API.patch === Applying: port: Provide pg_threads.h API. === using 'git am' to apply patch ./v3-0003-port-Native-Windows-mapping-for-pg_threads.h.patch === Applying: port: Native Windows mapping for pg_threads.h. === using 'git am' to apply patch ./v3-0004-port-Use-pg_threads.h-API-for-pg_localconv_r.patch === Applying: port: Use pg_threads.h API for pg_localconv_r(). === using 'git am' to apply patch ./v3-0005-ecpg-Improve-variable-name.patch === Applying: ecpg: Improve variable name. === using 'git am' to apply patch ./v3-0006-ecpg-Use-pg_threads.h.patch === Applying: ecpg: Use pg_threads.h. === using 'git am' to apply patch ./v3-0007-pgbench-Use-pg_threads.h.patch === Applying: pgbench: Use pg_threads.h. Using index info to reconstruct a base tree... M configure M configure.ac M meson.build M src/bin/pgbench/pgbench.c Falling back to patching base and 3-way merge... Removing src/port/pthread_barrier_wait.c Removing src/include/port/pg_pthread.h Auto-merging src/bin/pgbench/pgbench.c Auto-merging meson.build Auto-merging configure.ac Auto-merging configure === using 'git am' to apply patch ./v3-0008-libpq-Use-pg_threads.h.patch === Applying: libpq: Use pg_threads.h. === using 'git am' to apply patch ./v3-0009-pg_basebackup-Use-pg_threads.h.patch === Applying: pg_basebackup: Use pg_threads.h. Using index info to reconstruct a base tree... M src/bin/pg_basebackup/pg_basebackup.c M src/bin/pg_basebackup/t/010_pg_basebackup.pl Falling back to patching base and 3-way merge... Auto-merging src/bin/pg_basebackup/t/010_pg_basebackup.pl Auto-merging src/bin/pg_basebackup/pg_basebackup.c CONFLICT (content): Merge conflict in src/bin/pg_basebackup/pg_basebackup.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 pg_basebackup: Use pg_threads.h. 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 ./v3-0009-pg_basebackup-Use-pg_threads.h.patch === patching file src/bin/pg_basebackup/pg_basebackup.c Hunk #1 succeeded at 37 (offset 1 line). Hunk #2 succeeded at 172 (offset 1 line). Hunk #3 succeeded at 227 (offset 1 line). Hunk #4 succeeded at 278 (offset 1 line). Hunk #5 FAILED at 416. Hunk #6 succeeded at 506 (offset -2 lines). Hunk #7 succeeded at 540 (offset -2 lines). Hunk #8 succeeded at 570 with fuzz 2 (offset -4 lines). Hunk #9 succeeded at 585 (offset -5 lines). Hunk #10 succeeded at 657 (offset -5 lines). Hunk #11 succeeded at 966 (offset -5 lines). Hunk #12 FAILED at 2133. Hunk #13 succeeded at 2724 (offset -8 lines). 2 out of 13 hunks FAILED -- saving rejects to file src/bin/pg_basebackup/pg_basebackup.c.rej patching file src/bin/pg_basebackup/t/010_pg_basebackup.pl Hunk #1 succeeded at 1062 (offset 14 lines). Unstaged changes after reset: M src/bin/pg_basebackup/pg_basebackup.c M src/bin/pg_basebackup/t/010_pg_basebackup.pl Removing src/bin/pg_basebackup/pg_basebackup.c.rej === using 'git apply' to apply patch ./v3-0009-pg_basebackup-Use-pg_threads.h.patch === Applied patch to 'src/bin/pg_basebackup/pg_basebackup.c' with conflicts. Applied patch to 'src/bin/pg_basebackup/t/010_pg_basebackup.pl' cleanly. U src/bin/pg_basebackup/pg_basebackup.c diff --cc src/bin/pg_basebackup/pg_basebackup.c index c3b87a19e76,40d6c40486a..00000000000 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@@ -464,56 -422,21 +423,45 @@@ static boo reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finished) { - if (!has_xlogendptr) - { - #ifndef WIN32 - fd_set fds; - struct timeval tv = {0}; - int r; + static bool have_xlogendptr = false; ++<<<<<<< ours + /* + * Don't have the end pointer yet - check our pipe to see if it has + * been sent yet. + */ + FD_ZERO(&fds); + FD_SET(bgpipe[0], &fds); + + r = select(bgpipe[0] + 1, &fds, NULL, NULL, &tv); + if (r == 1) + { + ssize_t nread; + char xlogend[64] = {0}; + + nread = read(bgpipe[0], xlogend, sizeof(xlogend) - 1); + if (nread < 0) + pg_fatal("could not read from ready pipe: %m"); + + if (!pg_parse_lsn(xlogend, &xlogendptr)) + pg_fatal("could not parse write-ahead log location \"%s\"", + xlogend); + has_xlogendptr = 1; ++======= + /* + * Wait until xlogendptr has been set by the main thread. After it has + * been set, it is safe to read it without a lock. + */ + if (!have_xlogendptr) + { + pg_mtx_lock(&xlogendptr_lock); + have_xlogendptr = xlogendptr != 0; + pg_mtx_unlock(&xlogendptr_lock); ++>>>>>>> theirs - /* - * Fall through to check if we've reached the point further - * already. - */ - } - else - { - /* - * No data received on the pipe means we don't know the end - * position yet - so just say it's not time to stop yet. - */ + /* If it's not set yet, we just go back and wait until it shows up. */ + if (!have_xlogendptr) return false; - } - #else - - /* - * On win32, has_xlogendptr is set by the main thread, so if it's not - * set here, we just go back and wait until it shows up. - */ - return false; - #endif } /* @@@ -618,7 -528,10 +553,8 @@@ StartLogStreamer(char *startpos, uint3 int wal_compress_level) { logstreamer_param *param; - uint32 hi, - lo; char statusdir[MAXPGPATH]; + int error; param = pg_malloc0_object(logstreamer_param); param->timeline = timeline; @@@ -2198,66 -2090,41 +2112,58 @@@ BaseBackup(char *compression_algorithm exit(1); } - if (bgchild > 0) + if (includewal == STREAM_WAL) { - #ifndef WIN32 + int error; int status; ++<<<<<<< ours + pid_t r; +#else + DWORD status; + + /* + * get a pointer sized version of bgchild to avoid warnings about + * casting to a different size on WIN64. + */ + intptr_t bgchild_handle = bgchild; +#endif ++======= + uint32 hi, + lo; ++>>>>>>> theirs if (verbose) - pg_log_info("waiting for background process to finish streaming ..."); - - #ifndef WIN32 - if (write(bgpipe[1], xlogend, strlen(xlogend)) != strlen(xlogend)) - pg_fatal("could not send command to background pipe: %m"); - - /* Just wait for the background process to exit */ - r = waitpid(bgchild, &status, 0); - if (r == (pid_t) -1) - pg_fatal("could not wait for child process: %m"); - if (r != bgchild) - pg_fatal("child %d died, expected %d", (int) r, (int) bgchild); - if (status != 0) - pg_fatal("%s", wait_result_to_str(status)); - /* Exited normally, we're happy! */ - #else /* WIN32 */ + pg_log_info("waiting for WAL thread to finish streaming ..."); /* - * On Windows, since we are in the same process, we can just store the - * value directly in the variable, and then set the flag that says - * it's there. + * Since we are in the same process, we can just store the value + * directly in the variable, and then set the flag that says it's + * there. */ - if (sscanf(xlogend, "%X/%08X", &hi, &lo) != 2) + if (!pg_parse_lsn(xlogend, &xlogendptr)) pg_fatal("could not parse write-ahead log location \"%s\"", xlogend); ++<<<<<<< ours + InterlockedIncrement(&has_xlogendptr); ++======= + + /* + * XXX This could be done with atomics, once we can use those in + * frontend code. + */ + pg_mtx_lock(&xlogendptr_lock); + xlogendptr = ((uint64) hi) << 32 | lo; + pg_mtx_unlock(&xlogendptr_lock); ++>>>>>>> theirs /* First wait for the thread to exit */ - if (WaitForSingleObjectEx((HANDLE) bgchild_handle, INFINITE, FALSE) != - WAIT_OBJECT_0) - { - _dosmaperr(GetLastError()); - pg_fatal("could not wait for child thread: %m"); - } - if (GetExitCodeThread((HANDLE) bgchild_handle, &status) == 0) - { - _dosmaperr(GetLastError()); - pg_fatal("could not get child thread exit status: %m"); - } + if ((error = pg_thrd_join(wal_streamer_thread, + &status)) != pg_thrd_success) + pg_fatal("could not wait for child thread: %s", + pg_thrd_error_string_with_detail(error)); if (status != 0) - pg_fatal("child thread exited with error %u", - (unsigned int) status); + pg_fatal("child thread exited with error %d", status); /* Exited normally, we're happy */ - #endif } /* Free the configuration file contents */