diff options
author | Ian Kuehne <ian.kuehne@mongodb.com> | 2017-08-22 15:54:43 -0400 |
---|---|---|
committer | Ian Kuehne <ian.kuehne@mongodb.com> | 2017-08-25 12:40:57 -0400 |
commit | 1afa3b3b9631ccd38180bfd4305d3f0ece8a2fff (patch) | |
tree | 994681d1352842a36d2aa9bc54091f30db4bbbe6 /src/mongo/db/repl/dbcheck.h | |
parent | 1cde5401bd771a19bdbe8f1da5020be8add2a629 (diff) | |
download | mongo-1afa3b3b9631ccd38180bfd4305d3f0ece8a2fff.tar.gz |
SERVER-30762 Add dbCheck jstests.
Also includes miscellaneous fixes to make the new tests pass.
Diffstat (limited to 'src/mongo/db/repl/dbcheck.h')
-rw-r--r-- | src/mongo/db/repl/dbcheck.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/mongo/db/repl/dbcheck.h b/src/mongo/db/repl/dbcheck.h index bea6eae7ca8..bdac6b8e8ec 100644 --- a/src/mongo/db/repl/dbcheck.h +++ b/src/mongo/db/repl/dbcheck.h @@ -31,6 +31,7 @@ #include <memory> #include "mongo/db/catalog/health_log_gen.h" +#include "mongo/db/db_raii.h" #include "mongo/db/query/plan_executor.h" #include "mongo/db/repl/dbcheck_gen.h" #include "mongo/util/md5.hpp" @@ -38,7 +39,6 @@ namespace mongo { // Forward declarations. -class AutoGetCollection; class Collection; class OperationContext; @@ -158,14 +158,42 @@ private: }; /** - * Get a new, locked, collection handle. - * - * Equivalent to the AutoGetCollectionForRead constructor, except that if the collection is missing - * it will report that to the health log. + * Get the given database in MODE_S, while also blocking stepdown (SERVER-28544) and allowing writes + * to "local". + */ +class AutoGetDbForDbCheck { +public: + AutoGetDbForDbCheck(OperationContext* opCtx, const NamespaceString& nss); + + Database* getDb(void) { + return agd.getDb(); + } + +private: + Lock::DBLock localLock; + AutoGetDb agd; +}; + +/** + * Get the given collection in MODE_S, except that if the collection is missing it will report that + * to the health log, and it takes an IX lock on "local" as a workaround to SERVER-28544 and to + * ensure correct flush lock acquisition for MMAPV1. */ -std::unique_ptr<AutoGetCollection> getCollectionForDbCheck(OperationContext* opCtx, - const NamespaceString& nss, - const OplogEntriesEnum& type); +class AutoGetCollectionForDbCheck { +public: + AutoGetCollectionForDbCheck(OperationContext* opCtx, + const NamespaceString& nss, + const OplogEntriesEnum& type); + Collection* getCollection(void) { + return _collection; + } + +private: + AutoGetDbForDbCheck _agd; + Lock::CollectionLock _collLock; + Collection* _collection; +}; + /** * Gather the index information for a collection. |