summaryrefslogtreecommitdiff
path: root/src/mongo/db/ttl_collection_cache.cpp
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2021-03-01 12:57:30 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-01 19:02:31 +0000
commit4b95014f05755a197d81f97879a24c9a6e5c535d (patch)
tree2db456b3ae16b08c1a79cb54f0f391602dc6b07b /src/mongo/db/ttl_collection_cache.cpp
parentefe229ca2f1f68dc48974ef8c9c3f223047b88ac (diff)
downloadmongo-4b95014f05755a197d81f97879a24c9a6e5c535d.tar.gz
SERVER-54007 Support TTL deletions on time-series clustered indexes
Diffstat (limited to 'src/mongo/db/ttl_collection_cache.cpp')
-rw-r--r--src/mongo/db/ttl_collection_cache.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mongo/db/ttl_collection_cache.cpp b/src/mongo/db/ttl_collection_cache.cpp
index 00aa8af6227..27d1335510c 100644
--- a/src/mongo/db/ttl_collection_cache.cpp
+++ b/src/mongo/db/ttl_collection_cache.cpp
@@ -51,10 +51,10 @@ TTLCollectionCache& TTLCollectionCache::get(ServiceContext* ctx) {
return getTTLCollectionCache(ctx);
}
-void TTLCollectionCache::registerTTLInfo(std::pair<UUID, std::string>&& ttlInfo) {
+void TTLCollectionCache::registerTTLInfo(UUID uuid, const Info& info) {
{
stdx::lock_guard<Latch> lock(_ttlInfosLock);
- _ttlInfos.push_back(std::move(ttlInfo));
+ _ttlInfos[uuid].push_back(info);
}
if (MONGO_unlikely(hangTTLCollectionCacheAfterRegisteringInfo.shouldFail())) {
@@ -63,14 +63,21 @@ void TTLCollectionCache::registerTTLInfo(std::pair<UUID, std::string>&& ttlInfo)
}
}
-void TTLCollectionCache::deregisterTTLInfo(const std::pair<UUID, std::string>& ttlInfo) {
+void TTLCollectionCache::deregisterTTLInfo(UUID uuid, const Info& info) {
stdx::lock_guard<Latch> lock(_ttlInfosLock);
- auto collIter = std::find(_ttlInfos.begin(), _ttlInfos.end(), ttlInfo);
- fassert(40220, collIter != _ttlInfos.end());
- _ttlInfos.erase(collIter);
+ auto infoIt = _ttlInfos.find(uuid);
+ fassert(5400705, infoIt != _ttlInfos.end());
+ auto& [_, infoVec] = *infoIt;
+
+ auto iter = std::find(infoVec.begin(), infoVec.end(), info);
+ fassert(40220, iter != infoVec.end());
+ infoVec.erase(iter);
+ if (infoVec.empty()) {
+ _ttlInfos.erase(infoIt);
+ }
}
-std::vector<std::pair<UUID, std::string>> TTLCollectionCache::getTTLInfos() {
+TTLCollectionCache::InfoMap TTLCollectionCache::getTTLInfos() {
stdx::lock_guard<Latch> lock(_ttlInfosLock);
return _ttlInfos;
}