diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-11-04 15:46:40 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-11-05 11:21:19 -0500 |
commit | 5ca2daf551a2c631a5f573cb054406f5d49fbef5 (patch) | |
tree | b0a23d34ffdb376bac0b79ed17b5619cfc0d9b47 /src/third_party/wiredtiger/src/session/session_salvage.c | |
parent | 017704acdfc7517efadb3fab167bba06c025c01a (diff) | |
download | mongo-5ca2daf551a2c631a5f573cb054406f5d49fbef5.tar.gz |
SERVER-15953: add wiredtiger to third_party
Diffstat (limited to 'src/third_party/wiredtiger/src/session/session_salvage.c')
-rw-r--r-- | src/third_party/wiredtiger/src/session/session_salvage.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/third_party/wiredtiger/src/session/session_salvage.c b/src/third_party/wiredtiger/src/session/session_salvage.c new file mode 100644 index 00000000000..1512c6515ec --- /dev/null +++ b/src/third_party/wiredtiger/src/session/session_salvage.c @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2008-2014 WiredTiger, Inc. + * All rights reserved. + * + * See the file LICENSE for redistribution information. + */ + +#include "wt_internal.h" + +/* + * __wt_salvage -- + * Salvage a single file. + */ +int +__wt_salvage(WT_SESSION_IMPL *session, const char *cfg[]) +{ + WT_CKPT *ckptbase; + WT_DATA_HANDLE *dhandle; + WT_DECL_RET; + + dhandle = session->dhandle; + + /* + * XXX + * The salvage process reads and discards previous checkpoints, so the + * underlying block manager has to ignore any previous checkpoint + * entries when creating a new checkpoint, in other words, we can't use + * the metadata checkpoint list, it has all of those checkpoint listed + * and we don't care about them. Build a clean checkpoint list and use + * it instead. + * + * Don't first clear the metadata checkpoint list and call the function + * to get a list of checkpoints: a crash between clearing the metadata + * checkpoint list and creating a new checkpoint list would look like a + * create or open of a file without a checkpoint to roll-forward from, + * and the contents of the file would be discarded. + */ + WT_RET(__wt_calloc_def(session, 2, &ckptbase)); + WT_ERR(__wt_strdup(session, WT_CHECKPOINT, &ckptbase[0].name)); + F_SET(&ckptbase[0], WT_CKPT_ADD); + + WT_ERR(__wt_bt_salvage(session, ckptbase, cfg)); + + /* + * If no checkpoint was created, well, it's probably bad news, but there + * is nothing to do but clear any recorded checkpoints for the file. If + * a checkpoint was created, life is good, replace any existing list of + * checkpoints with the single new one. + */ + if (ckptbase[0].raw.data == NULL) + WT_ERR(__wt_meta_checkpoint_clear(session, dhandle->name)); + else + WT_ERR(__wt_meta_ckptlist_set( + session, dhandle->name, ckptbase, NULL)); + +err: __wt_meta_ckptlist_free(session, ckptbase); + return (ret); +} |