diff options
author | Eric Milkie <milkie@10gen.com> | 2018-05-23 15:37:08 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2018-05-25 11:22:27 -0400 |
commit | ec2b67ac05f7aaa05b990e18cd7c23109a2e6eb7 (patch) | |
tree | 899c4ef72d930ae526966de94383b6eb8b1e9251 /src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp | |
parent | 8f170e92c1e874dc1ac3ebcdda2fd38afa92b258 (diff) | |
download | mongo-ec2b67ac05f7aaa05b990e18cd7c23109a2e6eb7.tar.gz |
SERVER-34790 ensure proper locks are held when doing reads or writes, via debug checks
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index 52c6b1b60e8..b90916bc823 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -316,6 +316,7 @@ Status WiredTigerIndex::insert(OperationContext* opCtx, const BSONObj& key, const RecordId& id, bool dupsAllowed) { + dassert(opCtx->lockState()->isWriteLocked()); invariant(id.isNormal()); dassert(!hasFieldNames(key)); @@ -334,6 +335,7 @@ void WiredTigerIndex::unindex(OperationContext* opCtx, const BSONObj& key, const RecordId& id, bool dupsAllowed) { + dassert(opCtx->lockState()->isWriteLocked()); invariant(id.isNormal()); dassert(!hasFieldNames(key)); @@ -348,6 +350,7 @@ void WiredTigerIndex::unindex(OperationContext* opCtx, void WiredTigerIndex::fullValidate(OperationContext* opCtx, long long* numKeysOut, ValidateResults* fullResults) const { + dassert(opCtx->lockState()->isReadLocked()); if (fullResults && !WiredTigerRecoveryUnit::get(opCtx)->getSessionCache()->isEphemeral()) { int err = WiredTigerUtil::verifyTable(opCtx, _uri, &(fullResults->errors)); if (err == EBUSY) { @@ -387,6 +390,7 @@ void WiredTigerIndex::fullValidate(OperationContext* opCtx, bool WiredTigerIndex::appendCustomStats(OperationContext* opCtx, BSONObjBuilder* output, double scale) const { + dassert(opCtx->lockState()->isReadLocked()); { BSONObjBuilder metadata(output->subobjStart("metadata")); Status status = WiredTigerUtil::getApplicationMetadata(opCtx, uri(), &metadata); @@ -467,6 +471,7 @@ Status WiredTigerIndex::touch(OperationContext* opCtx) const { long long WiredTigerIndex::getSpaceUsedBytes(OperationContext* opCtx) const { + dassert(opCtx->lockState()->isReadLocked()); auto ru = WiredTigerRecoveryUnit::get(opCtx); WiredTigerSession* session = ru->getSession(); @@ -509,6 +514,7 @@ bool WiredTigerIndex::isDup(OperationContext* opCtx, WT_CURSOR* c, const BSONObj& key, const RecordId& id) { + dassert(opCtx->lockState()->isReadLocked()); invariant(unique()); // First check whether the key exists. @@ -542,6 +548,7 @@ Status WiredTigerIndex::initAsEmpty(OperationContext* opCtx) { } Status WiredTigerIndex::compact(OperationContext* opCtx) { + dassert(opCtx->lockState()->isWriteLocked()); WiredTigerSessionCache* cache = WiredTigerRecoveryUnit::get(opCtx)->getSessionCache(); if (!cache->isEphemeral()) { WT_SESSION* s = WiredTigerRecoveryUnit::get(opCtx)->getSession()->getSession(); @@ -845,6 +852,7 @@ public: boost::optional<IndexKeyEntry> seek(const BSONObj& key, bool inclusive, RequestedInfo parts) override { + dassert(_opCtx->lockState()->isReadLocked()); const BSONObj finalKey = stripFieldNames(key); const auto discriminator = _forward == inclusive ? KeyString::kExclusiveBefore : KeyString::kExclusiveAfter; @@ -859,6 +867,7 @@ public: boost::optional<IndexKeyEntry> seek(const IndexSeekPoint& seekPoint, RequestedInfo parts) override { + dassert(_opCtx->lockState()->isReadLocked()); // TODO: don't go to a bson obj then to a KeyString, go straight BSONObj key = IndexEntryComparison::makeQueryObject(seekPoint, _forward); @@ -1177,6 +1186,7 @@ public: } boost::optional<IndexKeyEntry> seekExact(const BSONObj& key, RequestedInfo parts) override { + dassert(_opCtx->lockState()->isReadLocked()); _query.resetToKey(stripFieldNames(key), _idx.ordering()); const WiredTigerItem keyItem(_query.getBuffer(), _query.getSize()); |