summaryrefslogtreecommitdiff
path: root/src/utilities
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-02-16 17:16:26 +1100
committerMichael Cahill <michael.cahill@mongodb.com>2015-02-16 17:16:26 +1100
commit3b2313c177609c6174ddca2ed945a898731644f9 (patch)
treebca25d2251cda19989122176f5475e682b98d0bf /src/utilities
parentdc396e1cd64871219b9e5a1b6558707feb70706e (diff)
parent2108f0f3edd5be1251f9a7878f2c8f3e62bd64fe (diff)
downloadmongo-3b2313c177609c6174ddca2ed945a898731644f9.tar.gz
Merge pull request #1666 from wiredtiger/wt-recover
Allow 'wt' command to run with or without recovery. #1651
Diffstat (limited to 'src/utilities')
-rw-r--r--src/utilities/util_main.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/utilities/util_main.c b/src/utilities/util_main.c
index ecfffb81e4b..19afc9b520d 100644
--- a/src/utilities/util_main.c
+++ b/src/utilities/util_main.c
@@ -11,11 +11,15 @@
const char *home = "."; /* Home directory */
const char *progname; /* Program name */
/* Global arguments */
-const char *usage_prefix = "[-Vv] [-C config] [-h home]";
+const char *usage_prefix = "[-Vv] [-R] [-C config] [-h home]";
int verbose; /* Verbose flag */
static const char *command; /* Command name */
+#define REC_ERROR "log=(recover=error)"
+#define REC_LOGOFF "log=(enabled=false)"
+#define REC_RECOVER "log=(recover=on)"
+
static int usage(void);
int
@@ -27,7 +31,7 @@ main(int argc, char *argv[])
size_t len;
int ch, major_v, minor_v, tret, (*func)(WT_SESSION *, int, char *[]);
char *p;
- const char *cmd_config, *config;
+ const char *cmd_config, *config, *rec_config;
conn = NULL;
p = NULL;
@@ -52,9 +56,16 @@ main(int argc, char *argv[])
return (EXIT_FAILURE);
}
- /* Check for standard options. */
cmd_config = config = NULL;
- while ((ch = __wt_getopt(progname, argc, argv, "C:h:Vv")) != EOF)
+ /*
+ * We default to returning an error if recovery needs to be run.
+ * Generally we expect this to be run after a clean shutdown.
+ * The printlog command disables logging entirely. If recovery is
+ * needed, the user can specify -R to run recovery.
+ */
+ rec_config = REC_ERROR;
+ /* Check for standard options. */
+ while ((ch = __wt_getopt(progname, argc, argv, "C:h:RVv")) != EOF)
switch (ch) {
case 'C': /* wiredtiger_open config */
cmd_config = __wt_optarg;
@@ -62,6 +73,9 @@ main(int argc, char *argv[])
case 'h': /* home directory */
home = __wt_optarg;
break;
+ case 'R': /* recovery */
+ rec_config = REC_RECOVER;
+ break;
case 'V': /* version */
printf("%s\n", wiredtiger_version(NULL, NULL, NULL));
return (EXIT_SUCCESS);
@@ -120,6 +134,7 @@ main(int argc, char *argv[])
case 'p':
if (strcmp(command, "printlog") == 0)
func = util_printlog;
+ rec_config = REC_LOGOFF;
break;
case 'r':
if (strcmp(command, "read") == 0)
@@ -154,15 +169,22 @@ main(int argc, char *argv[])
return (usage());
/* Build the configuration string, as necessary. */
- if (config == NULL)
- config = cmd_config;
- else if (cmd_config != NULL) {
- len = strlen(cmd_config) + strlen(config) + 10;
+ if (cmd_config != NULL || rec_config != NULL) {
+ len = 10; /* some slop */
+ if (config != NULL)
+ len += strlen(config);
+ if (cmd_config != NULL)
+ len += strlen(cmd_config);
+ if (rec_config != NULL)
+ len += strlen(rec_config);
if ((p = malloc(len)) == NULL) {
ret = util_err(errno, NULL);
goto err;
}
- (void)snprintf(p, len, "%s,%s", config, cmd_config);
+ (void)snprintf(p, len, "%s,%s,%s",
+ config == NULL ? "" : config,
+ cmd_config == NULL ? "" : cmd_config,
+ rec_config == NULL ? "" : rec_config);
config = p;
}
@@ -201,6 +223,7 @@ usage(void)
"global options:\n"
"\t" "-C\twiredtiger_open configuration\n"
"\t" "-h\tdatabase directory\n"
+ "\t" "-R\trun recovery if configured\n"
"\t" "-V\tdisplay library version and exit\n"
"\t" "-v\tverbose\n");
fprintf(stderr,