summaryrefslogtreecommitdiff
path: root/src/bin/initgtm
diff options
context:
space:
mode:
authorPavan Deolasee2016-02-04 13:33:34 +0000
committerPavan Deolasee2016-10-18 09:48:14 +0000
commit076dae8ff2a956ecffb1588c9735a92bc0bca09c (patch)
treec920bb2295b7939b828a3e538d494364b3159828 /src/bin/initgtm
parent83bcfb83b82ff1112611b43b5f8ccf771377bcab (diff)
If we don't find GTM control file on startup, look for the temporary control
file and use that. While updating the control file, GTM first writes updated content to a temp file, then deletes the old file and renames the temp to the control file. But in a rare situation, its possible that GTM may exit before renaming the temp file. In such cases, we should use the temp file after renaming it to the orignal file. More improvements in this area are necessary. P.S. This commit gets distinction to be the first commit, pushed from 41000 feet in the air ;-)
Diffstat (limited to 'src/bin/initgtm')
-rw-r--r--src/bin/initgtm/initgtm.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/bin/initgtm/initgtm.c b/src/bin/initgtm/initgtm.c
index f78f1f5d17..7e1d002e52 100644
--- a/src/bin/initgtm/initgtm.c
+++ b/src/bin/initgtm/initgtm.c
@@ -35,6 +35,7 @@
#include "miscadmin.h"
#include "postgres.h"
+#include "gtm/gtm.h"
/*
* these values are passed in by makefile defines
@@ -87,6 +88,7 @@ static void set_input(char **dest, char *filename);
static void check_input(char *path);
static void set_null_conf(void);
static void setup_config(void);
+static void setup_control(void);
static void trapsig(int signum);
static void check_ok(void);
static void usage(const char *progname);
@@ -547,6 +549,27 @@ setup_config(void)
check_ok();
}
+/*
+ * set up all the control file
+ */
+static void
+setup_control(void)
+{
+ char path[MAXPGPATH];
+ char *controlline = NULL;
+
+ if (!is_gtm)
+ return;
+
+ fputs(_("creating control file ... "), stdout);
+ fflush(stdout);
+
+ snprintf(path, sizeof(path), "%s/gtm.control", pg_data);
+ writefile(path, &controlline);
+ chmod(path, S_IRUSR | S_IWUSR);
+
+ check_ok();
+}
/*
* signal handler in case we are interrupted.
@@ -1084,6 +1107,9 @@ main(int argc, char *argv[])
/* Now create all the text config files */
setup_config();
+ /* Now create the control file */
+ setup_control();
+
/* Get directory specification used to start this executable */
strcpy(bin_dir, argv[0]);
get_parent_directory(bin_dir);