From: Pavan Deolasee Date: Mon, 15 Oct 2018 08:19:22 +0000 (+0530) Subject: Fix couple of regressions introduced in the previous commit. X-Git-Tag: XL_10_R1~12 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=e9a0f37c0e63da2221afbf6e6549d895e2adac91;p=postgres-xl.git Fix couple of regressions introduced in the previous commit. The format of the GTM control file setup during `initgtm` was broken. Also, we failed to consider the case of GTM standby initialising which might pass a NULL File handle. --- diff --git a/src/bin/initgtm/initgtm.c b/src/bin/initgtm/initgtm.c index b14b7dd539..9b06b363d8 100644 --- a/src/bin/initgtm/initgtm.c +++ b/src/bin/initgtm/initgtm.c @@ -556,20 +556,22 @@ static void setup_control(void) { char path[MAXPGPATH]; - char controlline_bufs[3][MAXNAMLEN]; - char *controllines[4]; + char controlline_bufs[4][MAXNAMLEN]; + char *controllines[5]; if (!is_gtm) return; - snprintf(controlline_bufs[0], MAXNAMLEN, "version: %u", GTM_CONTROL_VERSION); - snprintf(controlline_bufs[1], MAXNAMLEN, "next_xid: %u", InitialGXIDValue_Default); - snprintf(controlline_bufs[2], MAXNAMLEN, "global_xmin: %u", InitialGXIDValue_Default); + snprintf(controlline_bufs[0], MAXNAMLEN, "version: %u\n", GTM_CONTROL_VERSION); + snprintf(controlline_bufs[1], MAXNAMLEN, "next_xid: %u\n", InitialGXIDValue_Default); + snprintf(controlline_bufs[2], MAXNAMLEN, "global_xmin: %u\n", InitialGXIDValue_Default); + snprintf(controlline_bufs[3], MAXNAMLEN, "snap_id: %u\n", 1); controllines[0] = strdup(controlline_bufs[0]); controllines[1] = strdup(controlline_bufs[1]); controllines[2] = strdup(controlline_bufs[2]); - controllines[3] = NULL; + controllines[3] = strdup(controlline_bufs[3]); + controllines[4] = NULL; fputs(_("creating control file ... "), stdout); fflush(stdout); diff --git a/src/gtm/main/main.c b/src/gtm/main/main.c index 7f33360c97..9b9d2909d7 100644 --- a/src/gtm/main/main.c +++ b/src/gtm/main/main.c @@ -2362,7 +2362,11 @@ GTM_RestoreTxnInfo(FILE *ctlf, GlobalTransactionId next_gxid, GTMControlFile))); } } - else + /* + * GTM control file handle is not passed during GTM standby initialization + * mode. That's not an ERROR case. + */ + else if (!Recovery_IsStandby()) { ereport(FATAL, (EINVAL,