summaryrefslogtreecommitdiff
path: root/src/include
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/include
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/include')
-rw-r--r--src/include/extern.h2
-rw-r--r--src/include/txn.h12
-rw-r--r--src/include/txn.i49
3 files changed, 51 insertions, 12 deletions
diff --git a/src/include/extern.h b/src/include/extern.h
index 87433ae6a9e..b6f0869999f 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -662,7 +662,7 @@ extern int WT_CDECL __wt_txnid_cmp(const void *v1, const void *v2);
extern void __wt_txn_release_snapshot(WT_SESSION_IMPL *session);
extern void __wt_txn_get_snapshot(WT_SESSION_IMPL *session);
extern void __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force);
-extern int __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[]);
+extern int __wt_txn_config(WT_SESSION_IMPL *session, const char *cfg[]);
extern void __wt_txn_release(WT_SESSION_IMPL *session);
extern int __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_txn_rollback(WT_SESSION_IMPL *session, const char *cfg[]);
diff --git a/src/include/txn.h b/src/include/txn.h
index 62f565c0535..dbaa11309ab 100644
--- a/src/include/txn.h
+++ b/src/include/txn.h
@@ -46,14 +46,14 @@ struct __wt_txn_global {
volatile int32_t scan_count;
/*
- * Track information about the running checkpoint. The transaction IDs
- * used when checkpointing are special. Checkpoints can run for a long
- * time so we keep them out of regular visibility checks. Eviction and
- * checkpoint operations know when they need to be aware of
- * checkpoint IDs.
+ * Track information about the running checkpoint. The transaction
+ * snapshot used when checkpointing are special. Checkpoints can run
+ * for a long time so we keep them out of regular visibility checks.
+ * Eviction and checkpoint operations know when they need to be aware
+ * of checkpoint transactions.
*/
+ volatile uint32_t checkpoint_id; /* Checkpoint's session ID */
volatile uint64_t checkpoint_gen;
- volatile uint64_t checkpoint_id;
volatile uint64_t checkpoint_snap_min;
WT_TXN_STATE *states; /* Per-session transaction states */
diff --git a/src/include/txn.i b/src/include/txn.i
index 9e8d9cee748..f0b0534ff4a 100644
--- a/src/include/txn.i
+++ b/src/include/txn.i
@@ -99,23 +99,31 @@ __wt_txn_oldest_id(WT_SESSION_IMPL *session)
WT_BTREE *btree;
WT_TXN_GLOBAL *txn_global;
uint64_t checkpoint_snap_min, oldest_id;
+ uint32_t checkpoint_id;
txn_global = &S2C(session)->txn_global;
btree = S2BT_SAFE(session);
/*
- * Take a local copy of ID in case they are updated while we are
+ * Take a local copy of these IDs in case they are updated while we are
* checking visibility.
*/
+ checkpoint_id = txn_global->checkpoint_id;
checkpoint_snap_min = txn_global->checkpoint_snap_min;
oldest_id = txn_global->oldest_id;
/*
- * If there is no active checkpoint or this handle is up to date with
- * the active checkpoint it's safe to ignore the checkpoint ID in the
- * visibility check.
+ * Checkpoint transactions often fall behind ordinary application
+ * threads. Take special effort to not keep changes pinned in cache
+ * if they are only required for the checkpoint and it has already
+ * seen them.
+ *
+ * If there is no active checkpoint, this session is doing the
+ * checkpoint, or this handle is up to date with the active checkpoint
+ * then it's safe to ignore the checkpoint ID in the visibility check.
*/
- if (checkpoint_snap_min != WT_TXN_NONE && (btree == NULL ||
+ if (checkpoint_snap_min != WT_TXN_NONE &&
+ checkpoint_id != session->id && (btree == NULL ||
btree->checkpoint_gen != txn_global->checkpoint_gen) &&
TXNID_LT(checkpoint_snap_min, oldest_id))
/*
@@ -206,6 +214,37 @@ __wt_txn_visible(WT_SESSION_IMPL *session, uint64_t id)
}
/*
+ * __wt_txn_begin --
+ * Begin a transaction.
+ */
+static int
+__wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[])
+{
+ WT_TXN *txn;
+
+ txn = &session->txn;
+ txn->isolation = session->isolation;
+ txn->txn_logsync = S2C(session)->txn_logsync;
+
+ if (cfg != NULL)
+ WT_RET(__wt_txn_config(session, cfg));
+
+ F_SET(txn, TXN_RUNNING);
+ if (txn->isolation == TXN_ISO_SNAPSHOT) {
+ if (session->ncursors > 0)
+ WT_RET(__wt_session_copy_values(session));
+
+ /*
+ * We're about to allocate a snapshot: if we need to block for
+ * eviction, it's better to do it beforehand.
+ */
+ WT_RET(__wt_cache_full_check(session));
+ __wt_txn_get_snapshot(session);
+ }
+ return (0);
+}
+
+/*
* __wt_txn_read --
* Get the first visible update in a list (or NULL if none are visible).
*/