diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp | 14 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h | 2 |
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 64ef576378a..da241c5e20e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -44,12 +44,18 @@ #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), _inUnitOfWork(false), _active(false), - _myTransactionCount(1), + _mySnapshotId(nextSnapshotId.fetchAndAdd(1)), _everStartedWrite(false) {} WiredTigerRecoveryUnit::~WiredTigerRecoveryUnit() { @@ -61,7 +67,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()); } @@ -206,12 +212,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 63e49c06c86..cbd6ad955d5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h @@ -131,7 +131,7 @@ private: bool _areWriteUnitOfWorksBanned = false; bool _inUnitOfWork; bool _active; - uint64_t _myTransactionCount; + uint64_t _mySnapshotId; bool _everStartedWrite; Timer _timer; RecordId _oplogReadTill; |