summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/all_indices_required_checker.h
diff options
context:
space:
mode:
authorRui Liu <rui.liu@mongodb.com>2022-04-07 14:41:25 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-07 15:38:34 +0000
commit65656c587aeb384c173be1b84d0b3057563417f4 (patch)
treee97a3ba8030205b862760dc683849547de2f0ecd /src/mongo/db/query/all_indices_required_checker.h
parent55ded8c1cefa67b3d7c1ceeb1e28a8f0bfa45e25 (diff)
downloadmongo-65656c587aeb384c173be1b84d0b3057563417f4.tar.gz
SERVER-63848 Extend AllIndicesRequiredChecker to allow multiple collections
Diffstat (limited to 'src/mongo/db/query/all_indices_required_checker.h')
-rw-r--r--src/mongo/db/query/all_indices_required_checker.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mongo/db/query/all_indices_required_checker.h b/src/mongo/db/query/all_indices_required_checker.h
index 49e9066ee39..d4217dda643 100644
--- a/src/mongo/db/query/all_indices_required_checker.h
+++ b/src/mongo/db/query/all_indices_required_checker.h
@@ -34,6 +34,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_catalog_entry.h"
+#include "mongo/db/query/multiple_collection_accessor.h"
namespace mongo {
@@ -45,10 +46,10 @@ class AllIndicesRequiredChecker {
public:
/**
* Constructs an 'AllIndicesRequiredChecker' which can be used later to ensure that none of the
- * indices for the given 'collection' have been dropped. The caller must hold the appropriate
- * db_raii object in order to read the collection's index catalog.
+ * indices from 'collections' have been dropped. The caller must hold the appropriate db_raii
+ * object in order to read the collection's index catalog.
*/
- explicit AllIndicesRequiredChecker(const CollectionPtr& collection);
+ explicit AllIndicesRequiredChecker(const MultipleCollectionAccessor& collections);
/**
* Throws a 'QueryPlanKilled' error if any of the indices which existed at the time of
@@ -57,14 +58,15 @@ public:
void check() const;
private:
- // This class holds weak pointers to all of the index catalog entries known at the time of
- // construction. Later, we can attempt to lock each weak pointer in order to determine whether
- // an index in the list has been destroyed. If we can lock the weak pointer, we need to check
- // the 'isDropped()' flag on the index catalog entry.
- std::vector<std::weak_ptr<const IndexCatalogEntry>> _indexCatalogEntries;
+ void saveIndicesForCollection(const CollectionPtr& collection);
- // The names of the indices above. Used for error reporting.
- std::vector<std::string> _indexNames;
+ // This map of map holds weak pointers to all of the index catalog entries known at the time of
+ // construction, grouped first by collection namespace then by index name. Later, we can attempt
+ // to lock each weak pointer in order to determine whether an index in the list has been
+ // destroyed. If we can lock the weak pointer, we need to check the 'isDropped()' flag on the
+ // index catalog entry.
+ std::map<NamespaceString, StringMap<std::weak_ptr<const IndexCatalogEntry>>>
+ _indexCatalogEntries;
};
} // namespace mongo