diff options
author | Mathias Stearn <mathias@10gen.com> | 2015-04-14 18:13:08 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2015-06-29 19:23:15 -0400 |
commit | 28be53c1c9721c4ef8a3046bb3546a1b63e759f6 (patch) | |
tree | bdfd20f4ef40f02ebbd6ad307fc04e201316f8ca /src/mongo/db/concurrency | |
parent | d7f068a0fb33b2c85d7909e03edbe65a25b2f8e0 (diff) | |
download | mongo-28be53c1c9721c4ef8a3046bb3546a1b63e759f6.tar.gz |
SERVER-18022 Read Majority Committed implementation for primary nodes
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency.h | 7 | ||||
-rw-r--r-- | src/mongo/db/concurrency/lock_manager_defs.h | 11 | ||||
-rw-r--r-- | src/mongo/db/concurrency/lock_state.cpp | 2 |
4 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp index ae0526bb535..5e3c686f03d 100644 --- a/src/mongo/db/concurrency/d_concurrency.cpp +++ b/src/mongo/db/concurrency/d_concurrency.cpp @@ -206,4 +206,9 @@ void Lock::ResourceLock::unlock() { } } +void synchronizeOnCappedInFlightResource(Locker* lockState) { + dassert(lockState->inAWriteUnitOfWork()); + Lock::ResourceLock{lockState, resourceCappedInFlight, MODE_IX}; // held until end of WUOW. +} + } // namespace mongo diff --git a/src/mongo/db/concurrency/d_concurrency.h b/src/mongo/db/concurrency/d_concurrency.h index b95b7b46fec..f6a115c61e9 100644 --- a/src/mongo/db/concurrency/d_concurrency.h +++ b/src/mongo/db/concurrency/d_concurrency.h @@ -280,4 +280,11 @@ public: ResourceLock _pbwm; }; }; + +/** + * Takes a lock on resourceCappedInFlight in MODE_IX which will be held until the end of your + * WUOW. This ensures that a MODE_X lock on this resource will wait for all in-flight capped + * inserts to either commit or rollback and block new ones from starting. + */ +void synchronizeOnCappedInFlightResource(Locker* txn); } diff --git a/src/mongo/db/concurrency/lock_manager_defs.h b/src/mongo/db/concurrency/lock_manager_defs.h index 63c3e6ebf50..86bce16a659 100644 --- a/src/mongo/db/concurrency/lock_manager_defs.h +++ b/src/mongo/db/concurrency/lock_manager_defs.h @@ -184,7 +184,8 @@ public: SINGLETON_INVALID = 0, SINGLETON_PARALLEL_BATCH_WRITER_MODE, SINGLETON_GLOBAL, - SINGLETON_MMAPV1_FLUSH + SINGLETON_MMAPV1_FLUSH, + SINGLETON_CAPPED_IN_FLIGHT, }; ResourceId() : _fullHash(0) {} @@ -260,6 +261,14 @@ extern const ResourceId resourceIdAdminDB; // TODO: Merge this with resourceIdGlobal extern const ResourceId resourceIdParallelBatchWriterMode; +// Everywhere that starts in-flight capped inserts which allocate capped collection RecordIds in +// a way that could trigger hiding of newer records takes this lock in MODE_IX and holds it +// until the end of their WriteUnitOfWork. +// +// Threads that need a consistent view of the world can lock this in MODE_X to prevent +// concurrent in-flight capped inserts. +extern const ResourceId resourceCappedInFlight; + /** * Interface on which granted lock requests will be notified. See the contract for the notify * method for more information and also the LockManager::lock call. diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 37ca3c7f611..008646a586e 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -912,5 +912,7 @@ const ResourceId resourceIdOplog = ResourceId(RESOURCE_COLLECTION, StringData("l const ResourceId resourceIdAdminDB = ResourceId(RESOURCE_DATABASE, StringData("admin")); const ResourceId resourceIdParallelBatchWriterMode = ResourceId(RESOURCE_GLOBAL, ResourceId::SINGLETON_PARALLEL_BATCH_WRITER_MODE); +const ResourceId resourceCappedInFlight = + ResourceId(RESOURCE_METADATA, ResourceId::SINGLETON_CAPPED_IN_FLIGHT); } // namespace mongo |