summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorShin Yee Tan <shinyee.tan@mongodb.com>2022-10-18 14:39:47 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-18 16:48:55 +0000
commitd03513d69058626ed48812e41bf444c50655e6fa (patch)
treee1178b97dc2f9460ae4b42e18106665f7ba7091d /src/mongo
parent8981e5b8f9be7c719d8264dede6694cde0258a5d (diff)
downloadmongo-d03513d69058626ed48812e41bf444c50655e6fa.tar.gz
SERVER-70556 Clean up index catalog counter methods
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/capped_collection_maintenance.cpp2
-rw-r--r--src/mongo/db/catalog/collection_catalog_test.cpp20
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp2
-rw-r--r--src/mongo/db/catalog/database_impl.cpp4
-rw-r--r--src/mongo/db/catalog/database_test.cpp4
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp6
-rw-r--r--src/mongo/db/catalog/drop_indexes.cpp4
-rw-r--r--src/mongo/db/catalog/index_catalog.h6
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp25
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.h8
-rw-r--r--src/mongo/db/commands/create_indexes_cmd.cpp2
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp2
-rw-r--r--src/mongo/db/index_builds_coordinator_test.cpp18
-rw-r--r--src/mongo/db/repl/storage_interface_impl_test.cpp4
-rw-r--r--src/mongo/db/stats/storage_stats.cpp2
-rw-r--r--src/mongo/dbtests/clienttests.cpp6
-rw-r--r--src/mongo/dbtests/indexcatalogtests.cpp6
17 files changed, 59 insertions, 62 deletions
diff --git a/src/mongo/db/catalog/capped_collection_maintenance.cpp b/src/mongo/db/catalog/capped_collection_maintenance.cpp
index 688531a3d93..99095748188 100644
--- a/src/mongo/db/catalog/capped_collection_maintenance.cpp
+++ b/src/mongo/db/catalog/capped_collection_maintenance.cpp
@@ -216,7 +216,7 @@ void cappedTruncateAfter(OperationContext* opCtx,
bool inclusive) {
invariant(opCtx->lockState()->isCollectionLockedForMode(collection->ns(), MODE_X));
invariant(collection->isCapped());
- invariant(collection->getIndexCatalog()->numIndexesInProgress(opCtx) == 0);
+ invariant(collection->getIndexCatalog()->numIndexesInProgress() == 0);
collection->getRecordStore()->cappedTruncateAfter(
opCtx, end, inclusive, [&](OperationContext* opCtx, const RecordId& loc, RecordData data) {
diff --git a/src/mongo/db/catalog/collection_catalog_test.cpp b/src/mongo/db/catalog/collection_catalog_test.cpp
index 3ac65875960..885b29a8d75 100644
--- a/src/mongo/db/catalog/collection_catalog_test.cpp
+++ b/src/mongo/db/catalog/collection_catalog_test.cpp
@@ -1048,7 +1048,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenEarlierCollection) {
std::shared_ptr<Collection> coll =
CollectionCatalog::get(opCtx.get())->openCollection(opCtx.get(), nss, readTimestamp);
ASSERT(coll);
- ASSERT_EQ(0, coll->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(0, coll->getIndexCatalog()->numIndexesTotal());
// Verify that the CollectionCatalog returns the latest collection with the index present. This
// has to be done in an alternative client as we already have an open snapshot from an earlier
@@ -1059,7 +1059,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenEarlierCollection) {
auto latestColl = CollectionCatalog::get(newOpCtx.get())
->lookupCollectionByNamespaceForRead(newOpCtx.get(), nss);
ASSERT(latestColl);
- ASSERT_EQ(1, latestColl->getIndexCatalog()->numIndexesTotal(newOpCtx.get()));
+ ASSERT_EQ(1, latestColl->getIndexCatalog()->numIndexesTotal());
// Ensure the idents are shared between the collection instances.
ASSERT_NE(coll, latestColl);
@@ -1096,7 +1096,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenEarlierCollectionWithIndex) {
std::shared_ptr<Collection> coll =
CollectionCatalog::get(opCtx.get())->openCollection(opCtx.get(), nss, readTimestamp);
ASSERT(coll);
- ASSERT_EQ(1, coll->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(1, coll->getIndexCatalog()->numIndexesTotal());
// Verify that the CollectionCatalog returns the latest collection. This has to be done in an
// alternative client as we already have an open snapshot from an earlier point-in-time above.
@@ -1106,7 +1106,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenEarlierCollectionWithIndex) {
auto latestColl = CollectionCatalog::get(newOpCtx.get())
->lookupCollectionByNamespaceForRead(newOpCtx.get(), nss);
ASSERT(latestColl);
- ASSERT_EQ(2, latestColl->getIndexCatalog()->numIndexesTotal(newOpCtx.get()));
+ ASSERT_EQ(2, latestColl->getIndexCatalog()->numIndexesTotal());
// Ensure the idents are shared between the collection and index instances.
ASSERT_NE(coll, latestColl);
@@ -1502,7 +1502,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenExistingCollectionAndIndexesWithReape
CollectionCatalog::get(opCtx.get())->openCollection(opCtx.get(), nss, createIndexTs);
ASSERT(openedColl);
ASSERT_EQ(openedColl->getSharedIdent(), coll->getSharedIdent());
- ASSERT_EQ(2, openedColl->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(2, openedColl->getIndexCatalog()->numIndexesTotal());
// All idents are marked as in use and none should be removed.
storageEngine->dropIdentsOlderThan(opCtx.get(), Timestamp::max());
@@ -1518,7 +1518,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenExistingCollectionAndIndexesWithReape
CollectionCatalog::get(opCtx.get())->openCollection(opCtx.get(), nss, dropXIndexTs);
ASSERT(openedColl);
ASSERT_EQ(openedColl->getSharedIdent(), coll->getSharedIdent());
- ASSERT_EQ(1, openedColl->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(1, openedColl->getIndexCatalog()->numIndexesTotal());
std::vector<std::string> indexNames;
openedColl->getAllIndexes(&indexNames);
@@ -1541,7 +1541,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenExistingCollectionAndIndexesWithReape
->openCollection(opCtx.get(), nss, createCollectionTs);
ASSERT(openedColl);
ASSERT_EQ(openedColl->getSharedIdent(), coll->getSharedIdent());
- ASSERT_EQ(0, openedColl->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(0, openedColl->getIndexCatalog()->numIndexesTotal());
}
{
@@ -1615,7 +1615,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenNewCollectionAndIndexesWithReaper) {
std::shared_ptr<Collection> openedColl =
CollectionCatalog::get(opCtx.get())->openCollection(opCtx.get(), nss, createIndexTs);
ASSERT(openedColl);
- ASSERT_EQ(2, openedColl->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(2, openedColl->getIndexCatalog()->numIndexesTotal());
// All idents are marked as in use and none should be removed.
storageEngine->dropIdentsOlderThan(opCtx.get(), Timestamp::max());
@@ -1630,7 +1630,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenNewCollectionAndIndexesWithReaper) {
std::shared_ptr<Collection> openedColl =
CollectionCatalog::get(opCtx.get())->openCollection(opCtx.get(), nss, dropXIndexTs);
ASSERT(openedColl);
- ASSERT_EQ(1, openedColl->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(1, openedColl->getIndexCatalog()->numIndexesTotal());
std::vector<std::string> indexNames;
openedColl->getAllIndexes(&indexNames);
@@ -1651,7 +1651,7 @@ TEST_F(CollectionCatalogTimestampTest, OpenNewCollectionAndIndexesWithReaper) {
CollectionCatalog::get(opCtx.get())
->openCollection(opCtx.get(), nss, createCollectionTs);
ASSERT(openedColl);
- ASSERT_EQ(0, openedColl->getIndexCatalog()->numIndexesTotal(opCtx.get()));
+ ASSERT_EQ(0, openedColl->getIndexCatalog()->numIndexesTotal());
}
{
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index 2671d80ebe7..1928996934f 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -1304,7 +1304,7 @@ uint64_t CollectionImpl::getIndexFreeStorageBytes(OperationContext* const opCtx)
*/
Status CollectionImpl::truncate(OperationContext* opCtx) {
dassert(opCtx->lockState()->isCollectionLockedForMode(ns(), MODE_X));
- invariant(_indexCatalog->numIndexesInProgress(opCtx) == 0);
+ invariant(_indexCatalog->numIndexesInProgress() == 0);
// 1) store index specs
std::vector<BSONObj> indexSpecs;
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index fd637657b8e..618ecedc65a 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -286,7 +286,7 @@ void DatabaseImpl::getStats(OperationContext* opCtx,
BSONObjBuilder temp;
storageSize += collection->getRecordStore()->storageSize(opCtx, &temp);
- indexes += collection->getIndexCatalog()->numIndexesTotal(opCtx);
+ indexes += collection->getIndexCatalog()->numIndexesTotal();
indexSize += collection->getIndexSize(opCtx);
if (includeFreeStorage) {
@@ -427,7 +427,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx,
// Make sure no indexes builds are in progress.
// Use massert() to be consistent with IndexCatalog::dropAllIndexes().
- auto numIndexesInProgress = collection->getIndexCatalog()->numIndexesInProgress(opCtx);
+ auto numIndexesInProgress = collection->getIndexCatalog()->numIndexesInProgress();
massert(ErrorCodes::BackgroundOperationInProgressForNamespace,
str::stream() << "cannot drop collection " << nss << " (" << uuid << ") when "
<< numIndexesInProgress << " index builds in progress.",
diff --git a/src/mongo/db/catalog/database_test.cpp b/src/mongo/db/catalog/database_test.cpp
index f9b4e146ab2..e500c05ff93 100644
--- a/src/mongo/db/catalog/database_test.cpp
+++ b/src/mongo/db/catalog/database_test.cpp
@@ -244,7 +244,7 @@ void _testDropCollectionThrowsExceptionIfThereAreIndexesInProgress(OperationCont
}
auto indexCatalog = collection->getIndexCatalog();
- ASSERT_EQUALS(indexCatalog->numIndexesInProgress(opCtx), 0);
+ ASSERT_EQUALS(indexCatalog->numIndexesInProgress(), 0);
auto indexInfoObj = BSON("v" << int(IndexDescriptor::kLatestIndexVersion) << "key"
<< BSON("a" << 1) << "name"
<< "a_1");
@@ -262,7 +262,7 @@ void _testDropCollectionThrowsExceptionIfThereAreIndexesInProgress(OperationCont
wuow.commit();
});
- ASSERT_GREATER_THAN(indexCatalog->numIndexesInProgress(opCtx), 0);
+ ASSERT_GREATER_THAN(indexCatalog->numIndexesInProgress(), 0);
WriteUnitOfWork wuow(opCtx);
ASSERT_THROWS_CODE(db->dropCollection(opCtx, nss),
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index da4bcfd6d09..028f2eb644d 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -234,7 +234,7 @@ Status _abortIndexBuildsAndDrop(OperationContext* opCtx,
return Status::OK();
}
const NamespaceStringOrUUID dbAndUUID{coll->ns().dbName(), coll->uuid()};
- const int numIndexes = coll->getIndexCatalog()->numIndexesTotal(opCtx);
+ const int numIndexes = coll->getIndexCatalog()->numIndexesTotal();
while (true) {
// Save a copy of the namespace before yielding our locks.
@@ -286,7 +286,7 @@ Status _abortIndexBuildsAndDrop(OperationContext* opCtx,
// nss as a view while refreshing.
CollectionShardingState::get(opCtx, resolvedNss)->checkShardVersionOrThrow(opCtx);
- invariant(coll->getIndexCatalog()->numIndexesInProgress(opCtx) == 0);
+ invariant(coll->getIndexCatalog()->numIndexesInProgress() == 0);
status = dropFn(optionalAutoDb->getDb(), resolvedNss);
if (!status.isOK()) {
@@ -331,7 +331,7 @@ Status _dropCollectionForApplyOps(OperationContext* opCtx,
WriteUnitOfWork wunit(opCtx);
- int numIndexes = coll->getIndexCatalog()->numIndexesTotal(opCtx);
+ int numIndexes = coll->getIndexCatalog()->numIndexesTotal();
IndexBuildsCoordinator::get(opCtx)->assertNoIndexBuildInProgForCollection(coll->uuid());
status =
systemCollectionMode == DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops
diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp
index 25d50406adc..35e3fc31055 100644
--- a/src/mongo/db/catalog/drop_indexes.cpp
+++ b/src/mongo/db/catalog/drop_indexes.cpp
@@ -425,7 +425,7 @@ DropIndexesReply dropIndexes(OperationContext* opCtx,
}
DropIndexesReply reply;
- reply.setNIndexesWas((*collection)->getIndexCatalog()->numIndexesTotal(opCtx));
+ reply.setNIndexesWas((*collection)->getIndexCatalog()->numIndexesTotal());
const bool isWildcard =
stdx::holds_alternative<std::string>(index) && stdx::get<std::string>(index) == "*";
@@ -550,7 +550,7 @@ DropIndexesReply dropIndexes(OperationContext* opCtx,
invariant(isWildcard);
invariant(indexNames.size() == 1);
invariant(indexNames.front() == "*");
- invariant((*collection)->getIndexCatalog()->numIndexesInProgress(opCtx) == 0);
+ invariant((*collection)->getIndexCatalog()->numIndexesInProgress() == 0);
}
writeConflictRetry(
diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h
index 2736026190d..521be62b8f6 100644
--- a/src/mongo/db/catalog/index_catalog.h
+++ b/src/mongo/db/catalog/index_catalog.h
@@ -234,11 +234,11 @@ public:
virtual bool haveAnyIndexesInProgress() const = 0;
- virtual int numIndexesTotal(OperationContext* opCtx) const = 0;
+ virtual int numIndexesTotal() const = 0;
- virtual int numIndexesReady(OperationContext* opCtx) const = 0;
+ virtual int numIndexesReady() const = 0;
- virtual int numIndexesInProgress(OperationContext* opCtx) const = 0;
+ virtual int numIndexesInProgress() const = 0;
virtual bool haveIdIndex(OperationContext* opCtx) const = 0;
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index a57f0348ae8..21859986919 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -434,7 +434,7 @@ void IndexCatalogImpl::_logInternalState(OperationContext* opCtx,
LOGV2_ERROR(20365,
"Internal Index Catalog state",
- "numIndexesTotal"_attr = numIndexesTotal(opCtx),
+ "numIndexesTotal"_attr = numIndexesTotal(),
"numIndexesInCollectionCatalogEntry"_attr = numIndexesInCollectionCatalogEntry,
"numReadyIndexes"_attr = _readyIndexes.size(),
"numBuildingIndexes"_attr = _buildingIndexes.size(),
@@ -1195,7 +1195,7 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx,
}
}
- if (numIndexesTotal(opCtx) >= kMaxNumIndexesAllowed) {
+ if (numIndexesTotal() >= kMaxNumIndexesAllowed) {
string s = str::stream() << "add index fails, too many indexes for " << collection->ns()
<< " key:" << key;
LOGV2(20354,
@@ -1265,7 +1265,7 @@ void IndexCatalogImpl::dropIndexes(OperationContext* opCtx,
didExclude = true;
}
}
- invariant(seen == numIndexesTotal(opCtx));
+ invariant(seen == numIndexesTotal());
}
for (size_t i = 0; i < indexNamesToDrop.size(); i++) {
@@ -1293,11 +1293,11 @@ void IndexCatalogImpl::dropIndexes(OperationContext* opCtx,
long long numIndexesInCollectionCatalogEntry = collection->getTotalIndexCount();
if (!didExclude) {
- if (numIndexesTotal(opCtx) || numIndexesInCollectionCatalogEntry || _readyIndexes.size()) {
+ if (numIndexesTotal() || numIndexesInCollectionCatalogEntry || _readyIndexes.size()) {
_logInternalState(
opCtx, collection, numIndexesInCollectionCatalogEntry, indexNamesToDrop);
}
- fassert(17327, numIndexesTotal(opCtx) == 0);
+ fassert(17327, numIndexesTotal() == 0);
fassert(17328, numIndexesInCollectionCatalogEntry == 0);
fassert(17337, _readyIndexes.size() == 0);
}
@@ -1531,17 +1531,16 @@ bool IndexCatalogImpl::haveAnyIndexesInProgress() const {
return _buildingIndexes.size() > 0;
}
-int IndexCatalogImpl::numIndexesTotal(OperationContext* opCtx) const {
+int IndexCatalogImpl::numIndexesTotal() const {
return _readyIndexes.size() + _buildingIndexes.size() + _frozenIndexes.size();
}
-int IndexCatalogImpl::numIndexesReady(OperationContext* opCtx) const {
- std::vector<const IndexDescriptor*> itIndexes;
- auto ii = getIndexIterator(opCtx, InclusionPolicy::kReady);
- while (ii->more()) {
- itIndexes.push_back(ii->next()->descriptor());
- }
- return itIndexes.size();
+int IndexCatalogImpl::numIndexesReady() const {
+ return _readyIndexes.size();
+}
+
+int IndexCatalogImpl::numIndexesInProgress() const {
+ return _buildingIndexes.size();
}
bool IndexCatalogImpl::haveIdIndex(OperationContext* opCtx) const {
diff --git a/src/mongo/db/catalog/index_catalog_impl.h b/src/mongo/db/catalog/index_catalog_impl.h
index c9d21c5500b..b67f636c8ae 100644
--- a/src/mongo/db/catalog/index_catalog_impl.h
+++ b/src/mongo/db/catalog/index_catalog_impl.h
@@ -82,11 +82,9 @@ public:
bool haveAnyIndexes() const override;
bool haveAnyIndexesInProgress() const override;
- int numIndexesTotal(OperationContext* opCtx) const override;
- int numIndexesReady(OperationContext* opCtx) const override;
- int numIndexesInProgress(OperationContext* opCtx) const {
- return numIndexesTotal(opCtx) - numIndexesReady(opCtx) - _frozenIndexes.size();
- }
+ int numIndexesTotal() const override;
+ int numIndexesReady() const override;
+ int numIndexesInProgress() const override;
/**
* this is in "alive" until the Collection goes away
diff --git a/src/mongo/db/commands/create_indexes_cmd.cpp b/src/mongo/db/commands/create_indexes_cmd.cpp
index 6752ecb0207..6010cfcd64c 100644
--- a/src/mongo/db/commands/create_indexes_cmd.cpp
+++ b/src/mongo/db/commands/create_indexes_cmd.cpp
@@ -310,7 +310,7 @@ bool indexesAlreadyExist(OperationContext* opCtx,
return false;
}
- auto numIndexes = collection->getIndexCatalog()->numIndexesTotal(opCtx);
+ auto numIndexes = collection->getIndexCatalog()->numIndexesTotal();
reply->setNumIndexesBefore(numIndexes);
reply->setNumIndexesAfter(numIndexes);
reply->setNote(kAllIndexesAlreadyExist);
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 31330ad5185..6da862c5d00 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -3029,7 +3029,7 @@ int IndexBuildsCoordinator::getNumIndexesTotal(OperationContext* opCtx,
auto indexCatalog = collection->getIndexCatalog();
invariant(indexCatalog, str::stream() << "Collection is missing index catalog: " << nss);
- return indexCatalog->numIndexesTotal(opCtx);
+ return indexCatalog->numIndexesTotal();
}
std::vector<BSONObj> IndexBuildsCoordinator::prepareSpecListForCreate(
diff --git a/src/mongo/db/index_builds_coordinator_test.cpp b/src/mongo/db/index_builds_coordinator_test.cpp
index 461174709ad..ceeff4178c4 100644
--- a/src/mongo/db/index_builds_coordinator_test.cpp
+++ b/src/mongo/db/index_builds_coordinator_test.cpp
@@ -61,7 +61,7 @@ void IndexBuildsCoordinatorTest::createCollectionWithDuplicateDocs(OperationCont
wuow.commit();
}
- ASSERT_EQ(collection->getIndexCatalog()->numIndexesTotal(opCtx), 1);
+ ASSERT_EQ(collection->getIndexCatalog()->numIndexesTotal(), 1);
}
// Helper to refetch the Collection from the catalog in order to see any changes made to it
@@ -87,7 +87,7 @@ TEST_F(IndexBuildsCoordinatorTest, ForegroundUniqueEnforce) {
opCtx, collection->uuid(), spec, indexConstraints, fromMigrate),
AssertionException,
ErrorCodes::DuplicateKey);
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 1);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 1);
}
TEST_F(IndexBuildsCoordinatorTest, ForegroundUniqueRelax) {
@@ -106,7 +106,7 @@ TEST_F(IndexBuildsCoordinatorTest, ForegroundUniqueRelax) {
auto fromMigrate = false;
ASSERT_DOES_NOT_THROW(indexBuildsCoord->createIndex(
opCtx, collection->uuid(), spec, indexConstraints, fromMigrate));
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 2);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 2);
}
TEST_F(IndexBuildsCoordinatorTest, ForegroundIndexAlreadyExists) {
@@ -125,12 +125,12 @@ TEST_F(IndexBuildsCoordinatorTest, ForegroundIndexAlreadyExists) {
auto uuid = collection->uuid();
ASSERT_DOES_NOT_THROW(
indexBuildsCoord->createIndex(opCtx, uuid, spec, indexConstraints, fromMigrate));
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 2);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 2);
// Should silently return if the index already exists.
ASSERT_DOES_NOT_THROW(
indexBuildsCoord->createIndex(opCtx, uuid, spec, indexConstraints, fromMigrate));
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 2);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 2);
}
TEST_F(IndexBuildsCoordinatorTest, ForegroundIndexOptionsConflictEnforce) {
@@ -151,13 +151,13 @@ TEST_F(IndexBuildsCoordinatorTest, ForegroundIndexOptionsConflictEnforce) {
auto uuid = collection->uuid();
ASSERT_DOES_NOT_THROW(
indexBuildsCoord->createIndex(opCtx, uuid, spec1, indexConstraints, fromMigrate));
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 2);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 2);
ASSERT_THROWS_CODE(
indexBuildsCoord->createIndex(opCtx, uuid, spec2, indexConstraints, fromMigrate),
AssertionException,
ErrorCodes::IndexOptionsConflict);
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 2);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 2);
}
TEST_F(IndexBuildsCoordinatorTest, ForegroundIndexOptionsConflictRelax) {
@@ -178,12 +178,12 @@ TEST_F(IndexBuildsCoordinatorTest, ForegroundIndexOptionsConflictRelax) {
auto uuid = collection->uuid();
ASSERT_DOES_NOT_THROW(
indexBuildsCoord->createIndex(opCtx, uuid, spec1, indexConstraints, fromMigrate));
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 2);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 2);
// Should silently return in relax mode even if there are index option conflicts.
ASSERT_DOES_NOT_THROW(
indexBuildsCoord->createIndex(opCtx, uuid, spec2, indexConstraints, fromMigrate));
- ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(opCtx), 2);
+ ASSERT_EQ(coll(opCtx, nss)->getIndexCatalog()->numIndexesTotal(), 2);
}
} // namespace
diff --git a/src/mongo/db/repl/storage_interface_impl_test.cpp b/src/mongo/db/repl/storage_interface_impl_test.cpp
index 67bbcfc7c6d..6467d718c44 100644
--- a/src/mongo/db/repl/storage_interface_impl_test.cpp
+++ b/src/mongo/db/repl/storage_interface_impl_test.cpp
@@ -149,7 +149,7 @@ int _createIndexOnEmptyCollection(OperationContext* opCtx, NamespaceString nss,
.getStatus());
wunit.commit();
- return indexCatalog->numIndexesReady(opCtx);
+ return indexCatalog->numIndexesReady();
}
/**
@@ -616,7 +616,7 @@ void _testDestroyUncommitedCollectionBulkLoader(
// IndexCatalog::numIndexesTotal() includes unfinished indexes. We need to ensure that
// the bulk loader drops the unfinished indexes.
auto collIdxCat = coll->getIndexCatalog();
- ASSERT_EQUALS(0, collIdxCat->numIndexesTotal(opCtx));
+ ASSERT_EQUALS(0, collIdxCat->numIndexesTotal());
}
TEST_F(StorageInterfaceImplTest, DestroyingUncommittedCollectionBulkLoaderDropsIndexes) {
diff --git a/src/mongo/db/stats/storage_stats.cpp b/src/mongo/db/stats/storage_stats.cpp
index f092a96738f..f93838ae492 100644
--- a/src/mongo/db/stats/storage_stats.cpp
+++ b/src/mongo/db/stats/storage_stats.cpp
@@ -162,7 +162,7 @@ Status appendCollectionStorageStats(OperationContext* opCtx,
BSONObjBuilder indexDetails;
std::vector<std::string> indexBuilds;
- auto numIndexes = indexCatalog->numIndexesTotal(opCtx);
+ auto numIndexes = indexCatalog->numIndexesTotal();
if (collection->isClustered() && !collection->ns().isTimeseriesBucketsCollection()) {
// There is an implicit 'clustered' index on a clustered collection. Increment the total
// index count to reflect that.
diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp
index 427ec9926c6..3abf5681950 100644
--- a/src/mongo/dbtests/clienttests.cpp
+++ b/src/mongo/dbtests/clienttests.cpp
@@ -129,19 +129,19 @@ public:
const bool includeBuildUUIDs = false;
const int options = 0;
- ASSERT_EQUALS(1, indexCatalog()->numIndexesReady(&opCtx));
+ ASSERT_EQUALS(1, indexCatalog()->numIndexesReady());
// _id index
ASSERT_EQUALS(1U, db.getIndexSpecs(nss(), includeBuildUUIDs, options).size());
ASSERT_EQUALS(ErrorCodes::DuplicateKey,
dbtests::createIndex(&opCtx, ns(), BSON("y" << 1), true));
- ASSERT_EQUALS(1, indexCatalog()->numIndexesReady(&opCtx));
+ ASSERT_EQUALS(1, indexCatalog()->numIndexesReady());
ASSERT_EQUALS(1U, db.getIndexSpecs(nss(), includeBuildUUIDs, options).size());
ASSERT_OK(dbtests::createIndex(&opCtx, ns(), BSON("x" << 1), true));
- ASSERT_EQUALS(2, indexCatalog()->numIndexesReady(&opCtx));
+ ASSERT_EQUALS(2, indexCatalog()->numIndexesReady());
ASSERT_EQUALS(2U, db.getIndexSpecs(nss(), includeBuildUUIDs, options).size());
}
};
diff --git a/src/mongo/dbtests/indexcatalogtests.cpp b/src/mongo/dbtests/indexcatalogtests.cpp
index f8bf760bd82..092acdf75a5 100644
--- a/src/mongo/dbtests/indexcatalogtests.cpp
+++ b/src/mongo/dbtests/indexcatalogtests.cpp
@@ -83,12 +83,12 @@ public:
OperationContext& opCtx = *opCtxPtr;
dbtests::WriteContextForTests ctx(&opCtx, _nss.ns());
- int numFinishedIndexesStart = indexCatalog(&opCtx)->numIndexesReady(&opCtx);
+ int numFinishedIndexesStart = indexCatalog(&opCtx)->numIndexesReady();
dbtests::createIndex(&opCtx, _nss.ns(), BSON("x" << 1)).transitional_ignore();
dbtests::createIndex(&opCtx, _nss.ns(), BSON("y" << 1)).transitional_ignore();
- ASSERT_TRUE(indexCatalog(&opCtx)->numIndexesReady(&opCtx) == numFinishedIndexesStart + 2);
+ ASSERT_TRUE(indexCatalog(&opCtx)->numIndexesReady() == numFinishedIndexesStart + 2);
auto ii =
indexCatalog(&opCtx)->getIndexIterator(&opCtx, IndexCatalog::InclusionPolicy::kReady);
@@ -107,7 +107,7 @@ public:
}
}
- ASSERT_TRUE(indexesIterated == indexCatalog(&opCtx)->numIndexesReady(&opCtx));
+ ASSERT_TRUE(indexesIterated == indexCatalog(&opCtx)->numIndexesReady());
ASSERT_TRUE(foundIndex);
}
};