summaryrefslogtreecommitdiff
path: root/src/include/txn.i
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2014-09-11 10:30:52 +1000
committerMichael Cahill <michael.cahill@wiredtiger.com>2014-09-11 10:30:52 +1000
commite535a5202a60050f84cc2a0f8f5cc8c7392b9b20 (patch)
tree8106d15947d0b604efcf34f84dc1401540fdc7c9 /src/include/txn.i
parentcfab614cbb4d2c9f3443a0289eb47476344fb5a3 (diff)
downloadmongo-e535a5202a60050f84cc2a0f8f5cc8c7392b9b20.tar.gz
Change transaction ID allocation so that if transactions stop, the last ID becomes globally visible. We want post-increment semantics but our atomic primitive is pre-increment.
refs #1200
Diffstat (limited to 'src/include/txn.i')
-rw-r--r--src/include/txn.i21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/include/txn.i b/src/include/txn.i
index 3854429f8e4..81559bfe490 100644
--- a/src/include/txn.i
+++ b/src/include/txn.i
@@ -179,7 +179,7 @@ __wt_txn_read(WT_SESSION_IMPL *session, WT_UPDATE *upd)
/*
* __wt_txn_autocommit_check --
- * If an auto-commit transaction is required, start one.
+ * If an auto-commit transaction is required, start one.
*/
static inline int
__wt_txn_autocommit_check(WT_SESSION_IMPL *session)
@@ -195,23 +195,20 @@ __wt_txn_autocommit_check(WT_SESSION_IMPL *session)
}
/*
- * __wt_txn_current_id --
- * Get the current transaction ID.
- */
-static inline uint64_t
-__wt_txn_current_id(WT_SESSION_IMPL *session)
-{
- return (S2C(session)->txn_global.current);
-}
-
-/*
* __wt_txn_new_id --
* Allocate a new transaction ID.
*/
static inline uint64_t
__wt_txn_new_id(WT_SESSION_IMPL *session)
{
- return WT_ATOMIC_ADD(S2C(session)->txn_global.current, 1);
+ /*
+ * We want the global value to lead the allocated values, so that any
+ * allocated transaction ID eventually becomes globally visible. When
+ * there are no transactions running, the oldest_id will reach the
+ * global current ID, so we want post-increment semantics. Our atomic
+ * add primitive does pre-increment, so adjust the result here.
+ */
+ return WT_ATOMIC_ADD(S2C(session)->txn_global.current, 1) - 1;
}
/*