summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp14
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
index 7a41d0d7341..c87e036d16f 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
@@ -44,13 +44,19 @@
#include "mongo/util/stacktrace.h"
namespace mongo {
+namespace {
+// SnapshotIds need to be globally unique, as they are used in a WorkingSetMember to
+// determine if documents changed, but a different recovery unit may be used across a getMore,
+// so there is a chance the snapshot ID will be reused.
+AtomicUInt64 nextSnapshotId{1};
+} // namespace
WiredTigerRecoveryUnit::WiredTigerRecoveryUnit(WiredTigerSessionCache* sc)
: _sessionCache(sc),
_session(NULL),
_inUnitOfWork(false),
_active(false),
- _myTransactionCount(1),
+ _mySnapshotId(nextSnapshotId.fetchAndAdd(1)),
_everStartedWrite(false) {}
WiredTigerRecoveryUnit::~WiredTigerRecoveryUnit() {
@@ -66,7 +72,7 @@ void WiredTigerRecoveryUnit::reportState(BSONObjBuilder* b) const {
b->append("wt_inUnitOfWork", _inUnitOfWork);
b->append("wt_active", _active);
b->append("wt_everStartedWrite", _everStartedWrite);
- b->appendNumber("wt_myTransactionCount", static_cast<long long>(_myTransactionCount));
+ b->appendNumber("wt_mySnapshotId", static_cast<long long>(_mySnapshotId));
if (_active)
b->append("wt_millisSinceCommit", _timer.millis());
}
@@ -211,12 +217,12 @@ void WiredTigerRecoveryUnit::_txnClose(bool commit) {
LOG(3) << "WT rollback_transaction";
}
_active = false;
- _myTransactionCount++;
+ _mySnapshotId = nextSnapshotId.fetchAndAdd(1);
}
SnapshotId WiredTigerRecoveryUnit::getSnapshotId() const {
// TODO: use actual wiredtiger txn id
- return SnapshotId(_myTransactionCount);
+ return SnapshotId(_mySnapshotId);
}
Status WiredTigerRecoveryUnit::setReadFromMajorityCommittedSnapshot() {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
index b70b4bebfea..9b486c5893a 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
@@ -132,7 +132,7 @@ private:
bool _areWriteUnitOfWorksBanned = false;
bool _inUnitOfWork;
bool _active;
- uint64_t _myTransactionCount;
+ uint64_t _mySnapshotId;
bool _everStartedWrite;
Timer _timer;
RecordId _oplogReadTill;