summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2014-10-21 16:20:46 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2014-10-21 16:20:46 +1100
commit23d87e54873e49a2c57de8759c39675bbb554682 (patch)
tree08688757e8ad0338a0e4a8ba6e141ebea93883ba /src
parent8b412709059638888e403bf97d169edcf0b9eda9 (diff)
downloadmongo-23d87e54873e49a2c57de8759c39675bbb554682.tar.gz
If the metadata is updated, that update should ignore the running transaction. In particular, it should not be rolled back if WT_SESSION::rollback_transaction is called.
Diffstat (limited to 'src')
-rw-r--r--src/include/meta.h1
-rw-r--r--src/meta/meta_turtle.c3
-rw-r--r--src/txn/txn.c4
-rw-r--r--src/txn/txn_recover.c10
4 files changed, 12 insertions, 6 deletions
diff --git a/src/include/meta.h b/src/include/meta.h
index 22f1d0d2cba..e4d7fd64f94 100644
--- a/src/include/meta.h
+++ b/src/include/meta.h
@@ -20,6 +20,7 @@
#define WT_METAFILE_URI "file:WiredTiger.wt" /* Metadata file URI */
#define WT_IS_METADATA(dh) \
(strcmp((dh)->name, WT_METAFILE_URI) == 0)
+#define WT_METAFILE_ID 0 /* Metadata file ID */
#define WT_METADATA_VERSION "WiredTiger version" /* Version keys */
#define WT_METADATA_VERSION_STR "WiredTiger version string"
diff --git a/src/meta/meta_turtle.c b/src/meta/meta_turtle.c
index 2e3eca10833..d6060ebf47b 100644
--- a/src/meta/meta_turtle.c
+++ b/src/meta/meta_turtle.c
@@ -26,7 +26,8 @@ __metadata_config(WT_SESSION_IMPL *session, const char **metaconfp)
/* Create a turtle file with default values. */
WT_RET(__wt_scr_alloc(session, 0, &buf));
WT_ERR(__wt_buf_fmt(session, buf,
- "key_format=S,value_format=S,id=0,version=(major=%d,minor=%d)",
+ "key_format=S,value_format=S,id=%d,version=(major=%d,minor=%d)",
+ WT_METAFILE_ID,
WT_BTREE_MAJOR_VERSION_MAX, WT_BTREE_MINOR_VERSION_MAX));
cfg[1] = buf->data;
WT_ERR(__wt_config_collapse(session, cfg, &metaconf));
diff --git a/src/txn/txn.c b/src/txn/txn.c
index 24db4497112..041872877a6 100644
--- a/src/txn/txn.c
+++ b/src/txn/txn.c
@@ -419,6 +419,10 @@ __wt_txn_rollback(WT_SESSION_IMPL *session, const char *cfg[])
/* Rollback updates. */
for (i = 0, op = txn->mod; i < txn->mod_count; i++, op++) {
+ /* Metadata updates are never rolled back. */
+ if (op->fileid == WT_METAFILE_ID)
+ continue;
+
switch (op->type) {
case TXN_OP_BASIC:
case TXN_OP_INMEM:
diff --git a/src/txn/txn_recover.c b/src/txn/txn_recover.c
index 33cda218ebb..285dacbdc2c 100644
--- a/src/txn/txn_recover.c
+++ b/src/txn/txn_recover.c
@@ -12,7 +12,7 @@ typedef struct {
WT_SESSION_IMPL *session;
/* Files from the metadata, indexed by file ID. */
- struct {
+ struct WT_RECOVERY_FILE {
const char *uri; /* File URI. */
WT_CURSOR *c; /* Cursor used for recovery. */
WT_LSN ckpt_lsn; /* File's checkpoint LSN. */
@@ -58,7 +58,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r,
* is more recent than the last checkpoint. If there is no entry for a
* file, assume it was dropped or missing after a hot backup.
*/
- metadata_op = (id == 0);
+ metadata_op = (id == WT_METAFILE_ID);
if (r->metadata_only != metadata_op)
;
else if (id >= r->nfiles || r->files[id].uri == NULL) {
@@ -425,7 +425,7 @@ __wt_txn_recover(WT_CONNECTION_IMPL *conn)
WT_ERR(__wt_metadata_search(session, WT_METAFILE_URI, &config));
WT_ERR(__recovery_setup_file(&r, WT_METAFILE_URI, config));
WT_ERR(__wt_metadata_cursor(session, NULL, &metac));
- r.files[0].c = metac;
+ r.files[WT_METAFILE_ID].c = metac;
/*
* First, do a pass through the log to recover the metadata, and
@@ -434,12 +434,12 @@ __wt_txn_recover(WT_CONNECTION_IMPL *conn)
*/
if (!was_backup) {
r.metadata_only = 1;
- if (IS_INIT_LSN(&r.files[0].ckpt_lsn))
+ if (IS_INIT_LSN(&r.files[WT_METAFILE_ID].ckpt_lsn))
WT_ERR(__wt_log_scan(session,
NULL, WT_LOGSCAN_FIRST, __txn_log_recover, &r));
else
WT_ERR(__wt_log_scan(session,
- &r.files[0].ckpt_lsn, 0, __txn_log_recover, &r));
+ &r.files[WT_METAFILE_ID].ckpt_lsn, 0, __txn_log_recover, &r));
WT_ASSERT(session,
LOG_CMP(&r.ckpt_lsn, &conn->log->first_lsn) >= 0);