diff options
author | Eric Milkie <milkie@10gen.com> | 2019-02-21 08:43:31 -0500 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2019-02-21 12:50:32 -0500 |
commit | 2151d1d219bbaff918db0d43fcb812231c20d53a (patch) | |
tree | be41fb181fd933db41c2a3e72fd38c4607719cb6 | |
parent | 18caaa34aecc860adf797e712127b639292d8903 (diff) | |
download | mongo-2151d1d219bbaff918db0d43fcb812231c20d53a.tar.gz |
SERVER-39723 Revert "SERVER-25175 listIndexes command only includes ready indexes"r3.6.11-rc1
This reverts commit 1c922de9cac97065fb018f5d049566ecba803433.
10 files changed, 10 insertions, 101 deletions
diff --git a/jstests/noPassthrough/indexbg1.js b/jstests/noPassthrough/indexbg1.js index ae26b4a0494..d8a9c8e56a0 100644 --- a/jstests/noPassthrough/indexbg1.js +++ b/jstests/noPassthrough/indexbg1.js @@ -2,9 +2,6 @@ (function() { "use strict"; - - load("jstests/noPassthrough/libs/index_build.js"); - const conn = MongoRunner.runMongod({smallfiles: "", nojournal: ""}); assert.neq(null, conn, "mongod failed to start."); var db = conn.getDB("test"); @@ -60,7 +57,7 @@ // wait for indexing to start print("wait for indexing to start"); assert.soon(function() { - return getIndexBuildOpId(db) != -1; + return 2 === t.getIndexes().length; }, "no index created", 30000, 50); print("started."); sleep(1000); // there is a race between when the index build shows up in curop and diff --git a/jstests/noPassthrough/libs/index_build.js b/jstests/noPassthrough/libs/index_build.js deleted file mode 100644 index 3bb78889055..00000000000 --- a/jstests/noPassthrough/libs/index_build.js +++ /dev/null @@ -1,13 +0,0 @@ -// Returns the op id for the running index build, or -1 if there is no current index build. -function getIndexBuildOpId(db) { - const result = db.currentOp(); - assert.commandWorked(result); - let indexBuildOpId = -1; - - result.inprog.forEach(function(op) { - if (op.op == 'command' && 'createIndexes' in op.command) { - indexBuildOpId = op.opid; - } - }); - return indexBuildOpId; -} diff --git a/jstests/noPassthrough/list_indexes_only_ready_indexes.js b/jstests/noPassthrough/list_indexes_only_ready_indexes.js deleted file mode 100644 index 0e6b3dfd3fe..00000000000 --- a/jstests/noPassthrough/list_indexes_only_ready_indexes.js +++ /dev/null @@ -1,53 +0,0 @@ -// SERVER-25175: Test the listIndexes command only shows ready indexes. -(function() { - "use strict"; - - load("jstests/noPassthrough/libs/index_build.js"); - - const conn = MongoRunner.runMongod({smallfiles: "", nojournal: ""}); - assert.neq(null, conn, "mongod was unable to start up"); - - const testDB = conn.getDB("test"); - assert.commandWorked(testDB.dropDatabase()); - - function assertIndexes(coll, numIndexes, indexes) { - let res = coll.runCommand("listIndexes"); - assert.eq(numIndexes, res.cursor.firstBatch.length); - for (var i = 0; i < numIndexes; i++) { - assert.eq(indexes[i], res.cursor.firstBatch[i].name); - } - } - - let coll = testDB.list_indexes_only_ready_indexes; - coll.drop(); - assert.commandWorked(testDB.createCollection(coll.getName())); - assertIndexes(coll, 1, ["_id_"]); - assert.commandWorked(coll.createIndex({a: 1})); - assertIndexes(coll, 2, ["_id_", "a_1"]); - - assert.commandWorked( - testDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'alwaysOn'})); - const createIdx = startParallelShell( - "let coll = db.getSiblingDB('test').list_indexes_only_ready_indexes;" + - "assert.commandWorked(coll.createIndex({ b: 1 }, { background: true }));", - conn.port); - assert.soon(function() { - return getIndexBuildOpId(testDB) != -1; - }, "Index build operation not found after starting via parallelShell"); - - // Verify there is no third index. - assertIndexes(coll, 2, ["_id_", "a_1"]); - - assert.commandWorked( - testDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'off'})); - // Wait for the index build to stop. - assert.soon(function() { - return getIndexBuildOpId(testDB) == -1; - }); - const exitCode = createIdx(); - assert.eq(0, exitCode, 'expected shell to exit cleanly'); - - assertIndexes(coll, 3, ["_id_", "a_1", "b_1"]); - - MongoRunner.stopMongod(conn); -}()); diff --git a/jstests/noPassthroughWithMongod/indexbg_drop.js b/jstests/noPassthroughWithMongod/indexbg_drop.js index df346f13c9b..d7cbb4a781b 100644 --- a/jstests/noPassthroughWithMongod/indexbg_drop.js +++ b/jstests/noPassthroughWithMongod/indexbg_drop.js @@ -56,6 +56,14 @@ jsTest.log("Starting background indexing for test of: " + tojson(dc)); masterDB.getCollection(collection).ensureIndex({b: 1}); masterDB.getCollection(collection).ensureIndex({i: 1}, {background: true}); +assert.eq(3, masterDB.getCollection(collection).getIndexes().length); + +// Wait for the secondary to get the index entry +assert.soon(function() { + return 3 == secondDB.getCollection(collection).getIndexes().length; +}, "index not created on secondary (prior to drop)", 240000); + +jsTest.log("Index created and index entry exists on secondary"); // make sure the index build has started on secondary assert.soon(function() { diff --git a/src/mongo/db/catalog/collection_catalog_entry.h b/src/mongo/db/catalog/collection_catalog_entry.h index c2f3593f5af..2f17ba74efa 100644 --- a/src/mongo/db/catalog/collection_catalog_entry.h +++ b/src/mongo/db/catalog/collection_catalog_entry.h @@ -66,9 +66,6 @@ public: virtual void getAllIndexes(OperationContext* opCtx, std::vector<std::string>* names) const = 0; - virtual void getReadyIndexes(OperationContext* opCtx, - std::vector<std::string>* names) const = 0; - virtual BSONObj getIndexSpec(OperationContext* opCtx, StringData idxName) const = 0; /** diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index 4c43ddb7017..a6391248c0c 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -159,7 +159,7 @@ public: vector<string> indexNames; writeConflictRetry(opCtx, "listIndexes", ns.ns(), [&indexNames, &cce, &opCtx] { indexNames.clear(); - cce->getReadyIndexes(opCtx, &indexNames); + cce->getAllIndexes(opCtx, &indexNames); }); auto ws = make_unique<WorkingSet>(); diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.cpp b/src/mongo/db/storage/bson_collection_catalog_entry.cpp index 91e647324e9..d5ea5ae8249 100644 --- a/src/mongo/db/storage/bson_collection_catalog_entry.cpp +++ b/src/mongo/db/storage/bson_collection_catalog_entry.cpp @@ -146,16 +146,6 @@ void BSONCollectionCatalogEntry::getAllIndexes(OperationContext* opCtx, } } -void BSONCollectionCatalogEntry::getReadyIndexes(OperationContext* opCtx, - std::vector<std::string>* names) const { - MetaData md = _getMetaData(opCtx); - - for (unsigned i = 0; i < md.indexes.size(); i++) { - if (md.indexes[i].ready) - names->push_back(md.indexes[i].spec["name"].String()); - } -} - bool BSONCollectionCatalogEntry::isIndexMultikey(OperationContext* opCtx, StringData indexName, MultikeyPaths* multikeyPaths) const { diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.h b/src/mongo/db/storage/bson_collection_catalog_entry.h index b0b2c5b073e..b10743c75be 100644 --- a/src/mongo/db/storage/bson_collection_catalog_entry.h +++ b/src/mongo/db/storage/bson_collection_catalog_entry.h @@ -61,8 +61,6 @@ public: virtual void getAllIndexes(OperationContext* opCtx, std::vector<std::string>* names) const; - virtual void getReadyIndexes(OperationContext* opCtx, std::vector<std::string>* names) const; - virtual bool isIndexMultikey(OperationContext* opCtx, StringData indexName, MultikeyPaths* multikeyPaths) const; diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp index 3d7db3fdf8a..6188679d869 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp @@ -109,19 +109,6 @@ void NamespaceDetailsCollectionCatalogEntry::getAllIndexes(OperationContext* opC } } -void NamespaceDetailsCollectionCatalogEntry::getReadyIndexes( - OperationContext* opCtx, std::vector<std::string>* names) const { - NamespaceDetails::IndexIterator i = _details->ii(true); - while (i.more()) { - const IndexDetails& id = i.next(); - const BSONObj obj = _indexRecordStore->dataFor(opCtx, id.info.toRecordId()).toBson(); - const char* idxName = obj.getStringField("name"); - if (isIndexReady(opCtx, StringData(idxName))) { - names->push_back(idxName); - } - } -} - bool NamespaceDetailsCollectionCatalogEntry::isIndexMultikey(OperationContext* opCtx, StringData idxName, MultikeyPaths* multikeyPaths) const { diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h index a7607346ae6..614963861ed 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h @@ -68,8 +68,6 @@ public: void getAllIndexes(OperationContext* opCtx, std::vector<std::string>* names) const final; - void getReadyIndexes(OperationContext* opCtx, std::vector<std::string>* names) const final; - BSONObj getIndexSpec(OperationContext* opCtx, StringData idxName) const final; bool isIndexMultikey(OperationContext* opCtx, |