From b69e29bc0b7c420198773ed82b3900a013a0023e Mon Sep 17 00:00:00 2001 From: Grigory Smolkin Date: Wed, 18 Sep 2019 09:08:16 +0300 Subject: [PATCH] Improve compatibility between different versions of binary and instance --- src/configure.c | 7 +++++++ src/pg_probackup.c | 12 ++++++++++-- src/show.c | 8 ++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/configure.c b/src/configure.c index 5619cfd5..cbe97e28 100644 --- a/src/configure.c +++ b/src/configure.c @@ -571,7 +571,14 @@ readInstanceConfigFile(const char *instance_name) if (compress_alg) instance->compress_alg = parse_compress_alg(compress_alg); +#if PG_VERSION_NUM >= 110000 + /* If for some reason xlog-seg-size is missing, then set it to 16MB */ + if (!instance->xlog_seg_size) + instance->xlog_seg_size = DEFAULT_XLOG_SEG_SIZE; +#endif + return instance; + } static void diff --git a/src/pg_probackup.c b/src/pg_probackup.c index 5a463c69..09912bcb 100644 --- a/src/pg_probackup.c +++ b/src/pg_probackup.c @@ -564,10 +564,18 @@ main(int argc, char *argv[]) #if PG_VERSION_NUM >= 110000 /* Check xlog-seg-size option */ if (instance_name && - backup_subcmd != INIT_CMD && backup_subcmd != SHOW_CMD && + backup_subcmd != INIT_CMD && backup_subcmd != ADD_INSTANCE_CMD && backup_subcmd != SET_CONFIG_CMD && !IsValidWalSegSize(instance_config.xlog_seg_size)) - elog(ERROR, "Invalid WAL segment size %u", instance_config.xlog_seg_size); + { + /* If we are working with instance of PG<11 using PG11 binary, + * then xlog_seg_size is equal to zero. Manually set it to 16MB. + */ + if (instance_config.xlog_seg_size == 0) + instance_config.xlog_seg_size = DEFAULT_XLOG_SEG_SIZE; + else + elog(ERROR, "Invalid WAL segment size %u", instance_config.xlog_seg_size); + } #endif /* Sanity check of --backup-id option */ diff --git a/src/show.c b/src/show.c index b9a7b530..b75774a2 100644 --- a/src/show.c +++ b/src/show.c @@ -78,7 +78,11 @@ do_show(const char *instance_name, time_t requested_backup_id, bool show_archive { if (instance_name == NULL && requested_backup_id != INVALID_BACKUP_ID) - elog(ERROR, "You must specify --instance to use --backup_id option"); + elog(ERROR, "You must specify --instance to use (-i, --backup-id) option"); + + if (show_archive && + requested_backup_id != INVALID_BACKUP_ID) + elog(ERROR, "You cannot specify --archive and (-i, --backup-id) options together"); /* * if instance_name is not specified, @@ -105,7 +109,7 @@ do_show(const char *instance_name, time_t requested_backup_id, bool show_archive return 0; } - /* always use */ + /* always use */ else if (show_format == SHOW_JSON || requested_backup_id == INVALID_BACKUP_ID) {