From 591767150f5f91ccc3614e71977c47ce7a68786b Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Wed, 23 Mar 2022 13:25:26 -0400 Subject: [PATCH] pg_basebackup: Try to fix some failures on Windows. Commit ffd53659c46a54a6978bcb8c4424c1e157a2c0f1 messed up the mechanism that was being used to pass parameters to LogStreamerMain() on Windows. It worked on Linux because only Windows was using threads. Repair by moving the additional parameters added by that commit into the 'logstreamer_param' struct. Along the way, fix a compiler warning on builds without HAVE_LIBZ. Discussion: http://postgr.es/m/CA+TgmoY5=AmWOtMj3v+cySP2rR=Bt6EGyF_joAq4CfczMddKtw@mail.gmail.com --- src/backend/replication/basebackup_gzip.c | 3 +-- src/bin/pg_basebackup/pg_basebackup.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/backend/replication/basebackup_gzip.c b/src/backend/replication/basebackup_gzip.c index 703a91ba77..e4df57b121 100644 --- a/src/backend/replication/basebackup_gzip.c +++ b/src/backend/replication/basebackup_gzip.c @@ -61,8 +61,6 @@ const bbsink_ops bbsink_gzip_ops = { bbsink * bbsink_gzip_new(bbsink *next, bc_specification *compress) { - int compresslevel; - #ifndef HAVE_LIBZ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -70,6 +68,7 @@ bbsink_gzip_new(bbsink *next, bc_specification *compress) return NULL; /* keep compiler quiet */ #else bbsink_gzip *sink; + int compresslevel; Assert(next != NULL); diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 3e6977df1a..ed8d084d62 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -541,12 +541,12 @@ typedef struct char xlog[MAXPGPATH]; /* directory or tarfile depending on mode */ char *sysidentifier; int timeline; + WalCompressionMethod wal_compress_method; + int wal_compress_level; } logstreamer_param; static int -LogStreamerMain(logstreamer_param *param, - WalCompressionMethod wal_compress_method, - int wal_compress_level) +LogStreamerMain(logstreamer_param *param) { StreamCtl stream; @@ -575,8 +575,8 @@ LogStreamerMain(logstreamer_param *param, stream.do_sync); else stream.walmethod = CreateWalTarMethod(param->xlog, - wal_compress_method, - wal_compress_level, + param->wal_compress_method, + param->wal_compress_level, stream.do_sync); if (!ReceiveXlogStream(param->bgconn, &stream)) @@ -634,6 +634,8 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier, param = pg_malloc0(sizeof(logstreamer_param)); param->timeline = timeline; param->sysidentifier = sysidentifier; + param->wal_compress_method = wal_compress_method; + param->wal_compress_level = wal_compress_level; /* Convert the starting position */ if (sscanf(startpos, "%X/%X", &hi, &lo) != 2) @@ -724,7 +726,7 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier, int ret; /* in child process */ - ret = LogStreamerMain(param, wal_compress_method, wal_compress_level); + ret = LogStreamerMain(param); /* temp debugging aid to analyze 019_replslot_limit failures */ if (verbose)