summaryrefslogtreecommitdiff
path: root/src/mongo/db/ttl_collection_cache.h
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2022-08-26 08:08:11 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-26 13:06:53 +0000
commitcc3ae631bce7943fbda5182ff3b9d93d1125be40 (patch)
treeff8dd8dc8b6f0926d54c2b551c9d3fa99c27198f /src/mongo/db/ttl_collection_cache.h
parentacf81f84dabf486f74a84b99f04cd17efa35424f (diff)
downloadmongo-cc3ae631bce7943fbda5182ff3b9d93d1125be40.tar.gz
SERVER-68477 include 'expireAfterSeconds' type information when registering TTL indexes with the TTLCollectionCache
Diffstat (limited to 'src/mongo/db/ttl_collection_cache.h')
-rw-r--r--src/mongo/db/ttl_collection_cache.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/mongo/db/ttl_collection_cache.h b/src/mongo/db/ttl_collection_cache.h
index 8c70ce9f8d8..a8f00b6c6a6 100644
--- a/src/mongo/db/ttl_collection_cache.h
+++ b/src/mongo/db/ttl_collection_cache.h
@@ -54,16 +54,52 @@ public:
using IndexName = std::string;
// Specifies how a collection should expire data with TTL.
- using Info = stdx::variant<ClusteredId, IndexName>;
+ class Info {
+ public:
+ explicit Info(ClusteredId) : _isClustered(true), _isExpireAfterSecondsNaN(false) {}
+ Info(IndexName indexName, bool isExpireAfterSecondsNaN)
+ : _isClustered(false),
+ _indexName(std::move(indexName)),
+ _isExpireAfterSecondsNaN(isExpireAfterSecondsNaN) {}
+ bool isClustered() const {
+ return _isClustered;
+ }
+ IndexName getIndexName() const {
+ return _indexName;
+ }
+ bool isExpireAfterSecondsNaN() const {
+ return _isExpireAfterSecondsNaN;
+ }
+ void unsetExpireAfterSecondsNaN() {
+ _isExpireAfterSecondsNaN = false;
+ }
+
+ private:
+ bool _isClustered;
+ IndexName _indexName;
+ bool _isExpireAfterSecondsNaN;
+ };
// Caller is responsible for ensuring no duplicates are registered.
void registerTTLInfo(UUID uuid, const Info& info);
- void deregisterTTLInfo(UUID uuid, const Info& info);
+ void deregisterTTLIndexByName(UUID uuid, const IndexName& indexName);
+ void deregisterTTLClusteredIndex(UUID uuid);
+
+ /**
+ * Resets expireAfterSeconds flag on TTL index.
+ * For idempotency, this has no effect if index is not found.
+ */
+ void unsetTTLIndexExpireAfterSecondsNaN(UUID uuid, const IndexName& indexName);
using InfoMap = stdx::unordered_map<UUID, std::vector<Info>, UUID::Hash>;
InfoMap getTTLInfos();
private:
+ /**
+ * Shared implementation for deregistering TTL infos.
+ */
+ void _deregisterTTLInfo(UUID uuid, const Info& info);
+
Mutex _ttlInfosLock = MONGO_MAKE_LATCH("TTLCollectionCache::_ttlInfosLock");
InfoMap _ttlInfos;
};