diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-08-08 20:51:19 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-08-08 23:07:33 -0400 |
commit | 29ff5569f8bf8fba6b12b4b6b2c53591cd83cf10 (patch) | |
tree | d700df526674d67e82ad1208d369fc5d659e329f /src/mongo/db/storage/kv/kv_storage_engine_test.cpp | |
parent | ca4d34ece27104dd9bb62f9e46120e83398b71f3 (diff) | |
download | mongo-29ff5569f8bf8fba6b12b4b6b2c53591cd83cf10.tar.gz |
SERVER-35696 Provide a way to recover data files when lacking _mdb_catalog data, but have WiredTiger metadata
Diffstat (limited to 'src/mongo/db/storage/kv/kv_storage_engine_test.cpp')
-rw-r--r-- | src/mongo/db/storage/kv/kv_storage_engine_test.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mongo/db/storage/kv/kv_storage_engine_test.cpp b/src/mongo/db/storage/kv/kv_storage_engine_test.cpp index 997cf7826ff..f7e5655ebf8 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine_test.cpp +++ b/src/mongo/db/storage/kv/kv_storage_engine_test.cpp @@ -304,5 +304,25 @@ TEST_F(KVStorageEngineRepairTest, ReconcileSucceeds) { ASSERT(collectionExists(opCtx.get(), collNs)); } +TEST_F(KVStorageEngineRepairTest, LoadCatalogRecoversOrphansInCatalog) { + auto opCtx = cc().makeOperationContext(); + + const NamespaceString collNs("db.coll1"); + auto swIdentName = createCollection(opCtx.get(), collNs); + ASSERT_OK(swIdentName); + ASSERT(collectionExists(opCtx.get(), collNs)); + + AutoGetDb db(opCtx.get(), collNs.db(), LockMode::MODE_X); + ASSERT_OK(_storageEngine->getCatalog()->dropCollection(opCtx.get(), collNs.ns())); + ASSERT(!collectionExists(opCtx.get(), collNs)); + + // When in a repair context, loadCatalog recreates catalog entries for orphaned idents. + _storageEngine->loadCatalog(opCtx.get()); + NamespaceString orphanNs = NamespaceString("local.system.orphan-" + swIdentName.getValue()); + + ASSERT(identExists(opCtx.get(), swIdentName.getValue())); + ASSERT(collectionExists(opCtx.get(), orphanNs)); +} + } // namespace } // namespace mongo |