diff options
author | Luke Chen <luke.chen@mongodb.com> | 2019-03-05 13:25:53 +1100 |
---|---|---|
committer | Luke Chen <luke.chen@mongodb.com> | 2019-03-05 13:27:30 +1100 |
commit | 70f793946b5e3872d07f73908b2d45a31cce051d (patch) | |
tree | 70cd44000deed16e6c4a9179f326dba1c08953be /src/third_party/wiredtiger/src/meta/meta_turtle.c | |
parent | 6f3c3df4fc0abda76fd97e970ced4a01f0c48007 (diff) | |
download | mongo-70f793946b5e3872d07f73908b2d45a31cce051d.tar.gz |
Import wiredtiger: afdead1093b5c5b41dd54ddddf6f42d92bef1666 from branch mongodb-4.2
ref: 37e1570f82..afdead1093
for: 4.1.9
WT-4413 Add optional compact progress messages
WT-4465 Add documentation for a dhandle's lifecycle
WT-4514 Implement assert=durable_timestamp
WT-4517 Change WT data format to avoid writing stable timestamps
WT-4537 Fix WiredTiger cursor prev/next traversal failure on prepare retry
WT-4554 Enhance WT salvage to handle the case of corrupted WiredTiger.turtle
WT-4556 workgen: add synchronization points during run time
WT-4558 WiredTiger connection statistics cursor incorrectly provides doubled-up values
WT-4568 Operation tracking visualization incorrectly displays call stacks
WT-4573 Reducing calls to __wt_epoch from session reset
WT-4587 Parallelize the script that parses operation tracking files
WT-4595 Coverity "null pointer dereference" complaints
WT-4596 Simplify wt utility's session/connection handling
WT-4599 Show latency threshold violations in operation visualizations
WT-4605 workgen: read_write_storms.py needs a public domain notice
WT-4606 workgen: remove lsm from the default table type in wtperf emulation
WT-4613 Skip the wt4333_handle_locks test on OS X
WT-4615 Sync backup file before returning backup cursor
WT-4617 Cursor next/prev returns PREPARE_CONFLICT only once
Diffstat (limited to 'src/third_party/wiredtiger/src/meta/meta_turtle.c')
-rw-r--r-- | src/third_party/wiredtiger/src/meta/meta_turtle.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/third_party/wiredtiger/src/meta/meta_turtle.c b/src/third_party/wiredtiger/src/meta/meta_turtle.c index 3bd717b35cf..3531440e76f 100644 --- a/src/third_party/wiredtiger/src/meta/meta_turtle.c +++ b/src/third_party/wiredtiger/src/meta/meta_turtle.c @@ -189,11 +189,12 @@ int __wt_turtle_init(WT_SESSION_IMPL *session) { WT_DECL_RET; - char *metaconf; - bool exist_backup, exist_incr, exist_isrc, exist_turtle, load; + char *metaconf, *unused_value; + bool exist_backup, exist_incr, exist_isrc, exist_turtle; + bool load, loadTurtle; metaconf = NULL; - load = false; + load = loadTurtle = false; /* * Discard any turtle setup file left-over from previous runs. This @@ -202,6 +203,7 @@ __wt_turtle_init(WT_SESSION_IMPL *session) WT_RET(__wt_remove_if_exists(session, WT_METADATA_TURTLE_SET, false)); /* + * If we found a corrupted turtle file, then delete it and create a new. * We could die after creating the turtle file and before creating the * metadata file, or worse, the metadata file might be in some random * state. Make sure that doesn't happen: if we don't find the turtle @@ -221,6 +223,21 @@ __wt_turtle_init(WT_SESSION_IMPL *session) WT_RET(__wt_fs_exist(session, WT_METADATA_TURTLE, &exist_turtle)); if (exist_turtle) { /* + * Failure to read means a bad turtle file. Remove it and create + * a new turtle file. + */ + if (F_ISSET(S2C(session), WT_CONN_SALVAGE)) + WT_WITH_TURTLE_LOCK(session, + ret = __wt_turtle_read(session, + WT_METAFILE_URI, &unused_value)); + + if (ret != 0) { + WT_RET(__wt_remove_if_exists( + session, WT_METADATA_TURTLE, false)); + loadTurtle = true; + } + + /* * We need to detect the difference between a source database * that may have crashed with an incremental backup file * and a destination database that incorrectly ran recovery. @@ -258,7 +275,9 @@ __wt_turtle_init(WT_SESSION_IMPL *session) /* Create any bulk-loaded file stubs. */ WT_RET(__metadata_load_bulk(session)); + } + if (load || loadTurtle) { /* Create the turtle file. */ WT_RET(__metadata_config(session, &metaconf)); WT_WITH_TURTLE_LOCK(session, ret = @@ -329,8 +348,11 @@ err: WT_TRET(__wt_fclose(session, &fs)); * A file error or a missing key/value pair in the turtle file means * something has gone horribly wrong, except for the compatibility * setting which is optional. + * Failure to read the turtle file when salvaging means it can't be + * used for salvage. */ - if (ret == 0 || strcmp(key, WT_METADATA_COMPAT) == 0) + if (ret == 0 || strcmp(key, WT_METADATA_COMPAT) == 0 || + F_ISSET(S2C(session), WT_CONN_SALVAGE)) return (ret); WT_PANIC_RET(session, ret, "%s: fatal turtle file read error", WT_METADATA_TURTLE); |