diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-03-31 09:01:53 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-04-12 17:47:23 -0400 |
commit | b868de40b3a60233aff3370323b2325deafc0e8d (patch) | |
tree | 487ea00940e786a50243a8ff1de9dd380897acc2 /src/mongo/s | |
parent | 9c2e3c5396adb6bbaaf6a19e6c017b051f943ebf (diff) | |
download | mongo-b868de40b3a60233aff3370323b2325deafc0e8d.tar.gz |
SERVER-22611 Make CatalogCache::onStaleConfigError clear the passed cache entry
(cherry picked from commit 758bc2adcf2c83363d0fdfdef0cbd1cf3c800e62)
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/catalog_cache.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/s/catalog_cache.cpp b/src/mongo/s/catalog_cache.cpp index f9ee6cde0a0..cd62a3b0ce6 100644 --- a/src/mongo/s/catalog_cache.cpp +++ b/src/mongo/s/catalog_cache.cpp @@ -200,18 +200,22 @@ StatusWith<CachedCollectionRoutingInfo> CatalogCache::getShardedCollectionRoutin return getShardedCollectionRoutingInfoWithRefresh(opCtx, NamespaceString(ns)); } -void CatalogCache::onStaleConfigError(CachedCollectionRoutingInfo&& ccrt) { - if (!ccrt._cm) { +void CatalogCache::onStaleConfigError(CachedCollectionRoutingInfo&& ccriToInvalidate) { + // Ensure the move constructor of CachedCollectionRoutingInfo is invoked in order to clear the + // input argument so it can't be used anymore + auto ccri(ccriToInvalidate); + + if (!ccri._cm) { // Here we received a stale config error for a collection which we previously thought was // unsharded. - invalidateShardedCollection(ccrt._nss); + invalidateShardedCollection(ccri._nss); return; } // Here we received a stale config error for a collection which we previously though was sharded stdx::lock_guard<stdx::mutex> lg(_mutex); - auto it = _databases.find(NamespaceString(ccrt._cm->getns()).db()); + auto it = _databases.find(NamespaceString(ccri._cm->getns()).db()); if (it == _databases.end()) { // If the database does not exist, the collection must have been dropped so there is // nothing to invalidate. The getCollectionRoutingInfo will handle the reload of the @@ -221,7 +225,7 @@ void CatalogCache::onStaleConfigError(CachedCollectionRoutingInfo&& ccrt) { auto& collections = it->second->collections; - auto itColl = collections.find(ccrt._cm->getns()); + auto itColl = collections.find(ccri._cm->getns()); if (itColl == collections.end()) { // If the collection does not exist, this means it must have been dropped since the last // time we retrieved a cache entry for it. Doing nothing in this case will cause the @@ -230,7 +234,7 @@ void CatalogCache::onStaleConfigError(CachedCollectionRoutingInfo&& ccrt) { } else if (itColl->second.needsRefresh) { // Refresh has been scheduled for the collection already return; - } else if (itColl->second.routingInfo->getVersion() == ccrt._cm->getVersion()) { + } else if (itColl->second.routingInfo->getVersion() == ccri._cm->getVersion()) { // If the versions match, the last version of the routing information that we used is no // longer valid, so trigger a refresh. itColl->second.needsRefresh = true; |