diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/client.cpp | 24 | ||||
-rw-r--r-- | src/mongo/db/client.h | 5 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/batch_executor.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency.cpp | 22 | ||||
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency.h | 7 | ||||
-rw-r--r-- | src/mongo/db/concurrency/lock_state.h | 3 | ||||
-rw-r--r-- | src/mongo/db/concurrency/locker.h | 3 |
7 files changed, 15 insertions, 59 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp index 7601acc5d42..3f15582956c 100644 --- a/src/mongo/db/client.cpp +++ b/src/mongo/db/client.cpp @@ -228,43 +228,41 @@ namespace mongo { AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* txn, const std::string& ns) : _txn(txn), - _nss(ns), - _db(_txn, _nss.db(), MODE_IS), + _db(_txn, nsToDatabaseSubstring(ns), MODE_IS), _collLock(_txn->lockState(), ns, MODE_IS), _coll(NULL) { - _init(); + _init(ns, nsToCollectionSubstring(ns)); } AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* txn, const NamespaceString& nss) : _txn(txn), - _nss(nss), - _db(_txn, _nss.db(), MODE_IS), - _collLock(_txn->lockState(), _nss.toString(), MODE_IS), + _db(_txn, nss.db(), MODE_IS), + _collLock(_txn->lockState(), nss.toString(), MODE_IS), _coll(NULL) { - _init(); + _init(nss.toString(), nss.coll()); } - void AutoGetCollectionForRead::_init() { - massert(28535, "need a non-empty collection name", !_nss.coll().empty()); + void AutoGetCollectionForRead::_init(const std::string& ns, const StringData& coll) { + massert(28535, "need a non-empty collection name", !coll.empty()); // TODO: Client::Context legacy, needs to be removed _txn->getCurOp()->ensureStarted(); - _txn->getCurOp()->setNS(_nss.toString()); + _txn->getCurOp()->setNS(ns); // We have both the DB and collection locked, which the prerequisite to do a stable shard // version check. - ensureShardVersionOKOrThrow(_nss); + ensureShardVersionOKOrThrow(ns); // At this point, we are locked in shared mode for the database by the DB lock in the // constructor, so it is safe to load the DB pointer. if (_db.getDb()) { // TODO: Client::Context legacy, needs to be removed - _txn->getCurOp()->enter(_nss.toString().c_str(), _db.getDb()->getProfilingLevel()); + _txn->getCurOp()->enter(ns.c_str(), _db.getDb()->getProfilingLevel()); - _coll = _db.getDb()->getCollection(_txn, _nss); + _coll = _db.getDb()->getCollection(_txn, ns); } } diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h index 2c287915cfc..78696268ff3 100644 --- a/src/mongo/db/client.h +++ b/src/mongo/db/client.h @@ -77,6 +77,7 @@ namespace mongo { Database* getDb() const { return _db; } + private: const Lock::DBLock _dbLock; Database* const _db; @@ -140,11 +141,11 @@ namespace mongo { } private: - void _init(); + void _init(const std::string& ns, + const StringData& coll); const Timer _timer; OperationContext* const _txn; - const NamespaceString _nss; const AutoGetDb _db; const Lock::CollectionLock _collLock; diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index bfc0c4fce88..e5b2fc75418 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -1064,16 +1064,6 @@ namespace mongo { WriteOpResult result; insertOne(state, &result); - if (state->hasLock()) { - // Normally, unlocking records lock time stats on the active CurOp. However, - // insertOne() may not release the lock. In that case, record time by hand. - state->getLock().recordTime(); - // If we deschedule here, there could be substantial unaccounted locked time. - // Any time from here will be attributed to the next insert in the batch, or - // not attributed to any operation if this is the last op in the batch. - state->getLock().resetTime(); - } - incWriteStats(currInsertItem, result.getStats(), result.getError(), diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp index ac5e466efd1..9ae465747ae 100644 --- a/src/mongo/db/concurrency/d_concurrency.cpp +++ b/src/mongo/db/concurrency/d_concurrency.cpp @@ -112,13 +112,6 @@ namespace mongo { _relock(); } - void Lock::ScopedLock::resetTime() { - _timer.reset(); - } - - void Lock::ScopedLock::recordTime() { - } - void Lock::ScopedLock::_tempRelease() { // TempRelease is only used for global locks invariant(false); @@ -164,13 +157,11 @@ namespace mongo { invariant(_lockState->isW()); invariant(_lockState->unlockAll()); - recordTime(); } void Lock::GlobalWrite::_relock() { invariant(!_lockState->isLocked()); _lockState->lockGlobal(MODE_X); - resetTime(); } Lock::GlobalWrite::GlobalWrite(Locker* lockState, unsigned timeoutms) @@ -180,8 +171,6 @@ namespace mongo { if (result == LOCK_TIMEOUT) { throw DBTryLockTimeoutException(); } - - resetTime(); } Lock::GlobalWrite::~GlobalWrite() { @@ -189,7 +178,6 @@ namespace mongo { invariant(_lockState->isW() || _lockState->isR()); _lockState->unlockAll(); - recordTime(); } Lock::GlobalRead::GlobalRead(Locker* lockState, unsigned timeoutms) @@ -199,13 +187,10 @@ namespace mongo { if (result == LOCK_TIMEOUT) { throw DBTryLockTimeoutException(); } - - resetTime(); } Lock::GlobalRead::~GlobalRead() { _lockState->unlockAll(); - recordTime(); } Lock::DBLock::DBLock(Locker* lockState, const StringData& db, const LockMode mode) @@ -230,8 +215,6 @@ namespace mongo { else { _lockState->lock(_id, isRead ? MODE_S : MODE_X); } - - resetTime(); } void Lock::DBLock::relockWithMode(const LockMode newMode) { @@ -258,10 +241,7 @@ namespace mongo { void Lock::DBLock::unlockDB() { _lockState->unlock(_id); - // The last release reports time the lock was held - if (_lockState->unlockAll()) { - recordTime(); - } + _lockState->unlockAll(); } Lock::CollectionLock::CollectionLock(Locker* lockState, diff --git a/src/mongo/db/concurrency/d_concurrency.h b/src/mongo/db/concurrency/d_concurrency.h index 9ae00cf2db4..ac863f8e453 100644 --- a/src/mongo/db/concurrency/d_concurrency.h +++ b/src/mongo/db/concurrency/d_concurrency.h @@ -78,12 +78,6 @@ namespace mongo { public: virtual ~ScopedLock(); - // Start recording a new period, starting now() - void resetTime(); - - // Accrue elapsed lock time since last we called reset - void recordTime(); - protected: explicit ScopedLock(Locker* lockState, char type ); @@ -117,7 +111,6 @@ namespace mongo { ParallelBatchWriterSupport _pbws_lk; - Timer _timer; char _type; // 'r','w','R','W' }; diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h index 8ccf18aa297..c24f368c2b3 100644 --- a/src/mongo/db/concurrency/lock_state.h +++ b/src/mongo/db/concurrency/lock_state.h @@ -215,9 +215,6 @@ namespace mongo { virtual Lock::ScopedLock* getCurrentScopedLock() const; virtual void leaveScopedLock(Lock::ScopedLock* lock); - virtual void recordLockTime() { _scopedLk->recordTime(); } - virtual void resetLockTime() { _scopedLk->resetTime(); } - virtual void setIsBatchWriter(bool newValue) { _batchWriter = newValue; } virtual bool isBatchWriter() const { return _batchWriter; } virtual void setLockPendingParallelWriter(bool newValue) { diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h index c5d6e237da5..c50e7eddcd3 100644 --- a/src/mongo/db/concurrency/locker.h +++ b/src/mongo/db/concurrency/locker.h @@ -268,9 +268,6 @@ namespace mongo { virtual Lock::ScopedLock* getCurrentScopedLock() const = 0; virtual void leaveScopedLock(Lock::ScopedLock* lock) = 0; - virtual void recordLockTime() = 0; - virtual void resetLockTime() = 0; - // Used for the replication parallel log op application threads virtual void setIsBatchWriter(bool newValue) = 0; virtual bool isBatchWriter() const = 0; |