summaryrefslogtreecommitdiff
path: root/src/txn
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-06-29 15:04:43 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2015-06-29 15:04:43 +1000
commit3751941f5339b257d9fd9c19879f1a901facfbb6 (patch)
tree1ac0d47b6c1259d15036da3f54344ccbe14aa086 /src/txn
parent1e95bcc83853e69b8202914124b78029a4ad8617 (diff)
downloadmongo-3751941f5339b257d9fd9c19879f1a901facfbb6.tar.gz
SERVER-18875 Don't keep deleted pages during a checkpoint. Sync transaction up with WiredTiger 2.6 to ease back-porting, including picking up WT-1912.
Diffstat (limited to 'src/txn')
-rw-r--r--src/txn/txn.c32
-rw-r--r--src/txn/txn_ckpt.c15
2 files changed, 21 insertions, 26 deletions
diff --git a/src/txn/txn.c b/src/txn/txn.c
index 0e9df8993db..d488f7929e1 100644
--- a/src/txn/txn.c
+++ b/src/txn/txn.c
@@ -60,6 +60,7 @@ __wt_txn_release_snapshot(WT_SESSION_IMPL *session)
WT_ASSERT(session,
txn_state->snap_min == WT_TXN_NONE ||
session->txn.isolation == TXN_ISO_READ_UNCOMMITTED ||
+ session->id == S2C(session)->txn_global.checkpoint_id ||
!__wt_txn_visible_all(session, txn_state->snap_min));
txn_state->snap_min = WT_TXN_NONE;
@@ -77,9 +78,9 @@ __wt_txn_get_snapshot(WT_SESSION_IMPL *session)
WT_TXN *txn;
WT_TXN_GLOBAL *txn_global;
WT_TXN_STATE *s, *txn_state;
- uint64_t ckpt_id, current_id, id;
+ uint64_t current_id, id;
uint64_t prev_oldest_id, snap_min;
- uint32_t i, n, session_cnt;
+ uint32_t ckpt_id, i, n, session_cnt;
int32_t count;
conn = S2C(session);
@@ -121,7 +122,7 @@ __wt_txn_get_snapshot(WT_SESSION_IMPL *session)
ckpt_id = txn_global->checkpoint_id;
for (i = n = 0, s = txn_global->states; i < session_cnt; i++, s++) {
/* Skip the checkpoint transaction; it is never read from. */
- if (ckpt_id != WT_TXN_NONE && ckpt_id == s->id)
+ if (i == ckpt_id)
continue;
/*
@@ -181,8 +182,8 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force)
WT_SESSION_IMPL *oldest_session;
WT_TXN_GLOBAL *txn_global;
WT_TXN_STATE *s;
- uint64_t ckpt_id, current_id, id, oldest_id, prev_oldest_id, snap_min;
- uint32_t i, session_cnt;
+ uint64_t current_id, id, oldest_id, prev_oldest_id, snap_min;
+ uint32_t ckpt_id, i, session_cnt;
int32_t count;
int last_running_moved;
@@ -221,7 +222,7 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force)
ckpt_id = txn_global->checkpoint_id;
for (i = 0, s = txn_global->states; i < session_cnt; i++, s++) {
/* Skip the checkpoint transaction; it is never read from. */
- if (ckpt_id != WT_TXN_NONE && ckpt_id == s->id)
+ if (i == ckpt_id)
continue;
/*
@@ -271,7 +272,7 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force)
* Skip the checkpoint transaction; it is never read
* from.
*/
- if (ckpt_id != WT_TXN_NONE && ckpt_id == s->id)
+ if (i == ckpt_id)
continue;
if ((id = s->id) != WT_TXN_NONE &&
@@ -302,11 +303,11 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force)
}
/*
- * __wt_txn_begin --
- * Begin a transaction.
+ * __wt_txn_config --
+ * Configure a transaction.
*/
int
-__wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[])
+__wt_txn_config(WT_SESSION_IMPL *session, const char *cfg[])
{
WT_CONFIG_ITEM cval;
WT_TXN *txn;
@@ -314,9 +315,7 @@ __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[])
txn = &session->txn;
WT_RET(__wt_config_gets_def(session, cfg, "isolation", 0, &cval));
- if (cval.len == 0)
- txn->isolation = session->isolation;
- else
+ if (cval.len != 0)
txn->isolation =
WT_STRING_MATCH("snapshot", cval.str, cval.len) ?
TXN_ISO_SNAPSHOT :
@@ -335,18 +334,11 @@ __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[])
* !!! This is an unusual use of the config code: the "default" value
* we pass in is inherited from the connection.
*/
- txn->txn_logsync = S2C(session)->txn_logsync;
WT_RET(__wt_config_gets_def(session, cfg, "sync",
FLD_ISSET(txn->txn_logsync, WT_LOG_FLUSH) ? 1 : 0, &cval));
if (!cval.val)
txn->txn_logsync = 0;
- F_SET(txn, TXN_RUNNING);
- if (txn->isolation == TXN_ISO_SNAPSHOT) {
- if (session->ncursors > 0)
- WT_RET(__wt_session_copy_values(session));
- __wt_txn_get_snapshot(session);
- }
return (0);
}
diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c
index 955a48a5979..8be05734190 100644
--- a/src/txn/txn_ckpt.c
+++ b/src/txn/txn_ckpt.c
@@ -439,12 +439,15 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
/* Ensure a transaction ID is allocated prior to sharing it globally */
WT_ERR(__wt_txn_id_check(session));
+
/*
- * Save a copy of the checkpoint transaction ID so that refresh can
- * skip the checkpoint IDs. Save a copy of the snap min so that
- * visibility checks for the checkpoint use the right ID.
+ * Save a copy of the checkpoint session ID so that refresh can skip
+ * the checkpoint transactions. We never do checkpoints in the default
+ * session with id zero. Save a copy of the snap min so that visibility
+ * checks for the checkpoint use the right ID.
*/
- txn_global->checkpoint_id = session->txn.id;
+ WT_ASSERT(session, session->id != 0);
+ txn_global->checkpoint_id = session->id;
txn_global->checkpoint_snap_min = session->txn.snap_min;
/*
@@ -475,7 +478,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
__wt_txn_release_snapshot(session);
/* Clear the global checkpoint transaction IDs */
- txn_global->checkpoint_id = WT_TXN_NONE;
+ txn_global->checkpoint_id = 0;
txn_global->checkpoint_snap_min = WT_TXN_NONE;
WT_ERR(__checkpoint_verbose_track(session,
@@ -551,7 +554,7 @@ err: /*
}
/* Ensure the checkpoint IDs are cleared on the error path. */
- txn_global->checkpoint_id = WT_TXN_NONE;
+ txn_global->checkpoint_id = 0;
txn_global->checkpoint_snap_min = WT_TXN_NONE;
/*