pg_basebackup: Try to fix some failures on Windows.
authorRobert Haas <rhaas@postgresql.org>
Wed, 23 Mar 2022 17:25:26 +0000 (13:25 -0400)
committerRobert Haas <rhaas@postgresql.org>
Wed, 23 Mar 2022 17:25:26 +0000 (13:25 -0400)
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
src/bin/pg_basebackup/pg_basebackup.c

index 703a91ba7763aea293740d385ab4ec3fbace9068..e4df57b121f57ea3aaec72610eb4059dd395cd33 100644 (file)
@@ -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);
 
index 3e6977df1aa6a8c6f8d67e8bc21af05c50f23fad..ed8d084d6298eab53556ca610e738afc4d5a939d 100644 (file)
@@ -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)