summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2016-04-07 17:10:40 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2016-04-07 17:10:40 +1000
commit94c171dbcd205aea68f77302ca749634e3a91d84 (patch)
tree4ea83da88c2ad2a20631a5076324f842a3518b34
parent5047aab6262c5ef92e802e9b9f8bb686d2b3bc8e (diff)
parent5535876ce00b27135a728dee4b5171ab0732481b (diff)
downloadmongo-94c171dbcd205aea68f77302ca749634e3a91d84.tar.gz
Merge branch 'develop' into mongodb-3.4
-rw-r--r--src/include/txn.i9
-rw-r--r--src/txn/txn_ckpt.c7
2 files changed, 11 insertions, 5 deletions
diff --git a/src/include/txn.i b/src/include/txn.i
index 40e2a6175d6..f5ca44c2ada 100644
--- a/src/include/txn.i
+++ b/src/include/txn.i
@@ -357,8 +357,13 @@ __wt_txn_id_alloc(WT_SESSION_IMPL *session, bool publish)
WT_PUBLISH(WT_SESSION_TXN_STATE(session)->id, id);
}
- ++txn_global->current;
- __wt_spin_unlock(session, &txn_global->id_lock);
+ /*
+ * Even though we are in a spinlock, readers are not. We rely on
+ * atomic reads of the current ID to create snapshots, so for unlocked
+ * reads to be well defined, we must use an atomic increment here.
+ */
+ (void)__wt_atomic_addv64(&txn_global->current, 1);
+ __wt_spin_unlock(session, &txn_global->id_lock);
return (id);
}
diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c
index fdbda26b781..27e18b254b8 100644
--- a/src/txn/txn_ckpt.c
+++ b/src/txn/txn_ckpt.c
@@ -441,14 +441,15 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
* Start the checkpoint for real.
*
* Bump the global checkpoint generation, used to figure out whether
- * checkpoint has visited a tree. There is no need for this to be
- * atomic: it is only written while holding the checkpoint lock.
+ * checkpoint has visited a tree. Use an atomic increment even though
+ * we are single-threaded because readers of the checkpoint generation
+ * don't hold the checkpoint lock.
*
* We do need to update it before clearing the checkpoint's entry out
* of the transaction table, or a thread evicting in a tree could
* ignore the checkpoint's transaction.
*/
- ++txn_global->checkpoint_gen;
+ (void)__wt_atomic_addv64(&txn_global->checkpoint_gen, 1);
WT_STAT_FAST_CONN_SET(session,
txn_checkpoint_generation, txn_global->checkpoint_gen);