diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2021-02-16 10:21:22 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-16 22:03:43 +0000 |
commit | e16a95eaac68ac2daa8f6f8b943b93763cd8dd5d (patch) | |
tree | b02e606bf5898835c5cb28e0ceab2c499e5f390b | |
parent | fefd2787643720bdf23f47558cbdcafd02e7452f (diff) | |
download | mongo-e16a95eaac68ac2daa8f6f8b943b93763cd8dd5d.tar.gz |
SERVER-54537 Improve diagnosability for invariant failure in WiredTigerRecordStore::waitForAllEarlierOplogWritesToBeVisible()
-rw-r--r-- | src/mongo/db/storage/recovery_unit.h | 9 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h | 2 |
3 files changed, 16 insertions, 8 deletions
diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h index a4b06e2f316..2e641cd94d0 100644 --- a/src/mongo/db/storage/recovery_unit.h +++ b/src/mongo/db/storage/recovery_unit.h @@ -647,7 +647,7 @@ public: kCommitting, }; - std::string toString(State state) const { + static std::string toString(State state) { switch (state) { case State::kInactive: return "Inactive"; @@ -665,6 +665,13 @@ public: MONGO_UNREACHABLE; } + /** + * Exposed for debugging purposes. + */ + State getState() { + return _getState(); + } + void setMustBeTimestamped() { _mustBeTimestamped = true; } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 33765cb8da0..420f933fc91 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -1976,7 +1976,14 @@ void WiredTigerRecordStore::appendCustomStats(OperationContext* opCtx, void WiredTigerRecordStore::waitForAllEarlierOplogWritesToBeVisible(OperationContext* opCtx) const { // Make sure that callers do not hold an active snapshot so it will be able to see the oplog // entries it waited for afterwards. - invariant(!_getRecoveryUnit(opCtx)->isActive()); + if (opCtx->recoveryUnit()->isActive()) { + opCtx->lockState()->dump(); + invariant(!opCtx->recoveryUnit()->isActive(), + str::stream() << "Unexpected open storage txn. RecoveryUnit state: " + << RecoveryUnit::toString(opCtx->recoveryUnit()->getState()) + << ", inMultiDocumentTransaction:" + << (opCtx->inMultiDocumentTransaction() ? "true" : "false")); + } auto oplogManager = _kvEngine->getOplogManager(); if (oplogManager->isRunning()) { @@ -2073,10 +2080,6 @@ RecordId WiredTigerRecordStore::_nextId(OperationContext* opCtx) { return out; } -WiredTigerRecoveryUnit* WiredTigerRecordStore::_getRecoveryUnit(OperationContext* opCtx) { - return checked_cast<WiredTigerRecoveryUnit*>(opCtx->recoveryUnit()); -} - class WiredTigerRecordStore::NumRecordsChange : public RecoveryUnit::Change { public: NumRecordsChange(WiredTigerRecordStore* rs, int64_t diff) : _rs(rs), _diff(diff) {} diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h index bdf19060444..16ebc2bc5e9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h @@ -290,8 +290,6 @@ private: class NumRecordsChange; class DataSizeChange; - static WiredTigerRecoveryUnit* _getRecoveryUnit(OperationContext* opCtx); - Status _insertRecords(OperationContext* opCtx, Record* records, const Timestamp* timestamps, |