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
This commit is contained in:
Robert Haas 2022-03-23 13:25:26 -04:00
parent 9d92582abf
commit 591767150f
2 changed files with 9 additions and 8 deletions

View 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);

View 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)