summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands
diff options
context:
space:
mode:
authorMarcos José Grillo Ramírez <marcos.grillo@mongodb.com>2020-09-05 15:01:13 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-09 22:27:23 +0000
commit377b8fe43916ff2c4e2ed35cb80548aeb8ba8c8d (patch)
treee2036dd117f4b5f2255faedc1ef02853d879ae2c /src/mongo/s/commands
parentf9d4a15397585a8f00ea0afa9864531e1f4ed5fb (diff)
downloadmongo-377b8fe43916ff2c4e2ed35cb80548aeb8ba8c8d.tar.gz
SERVER-46199 Make the collection CatalogCache support causal consistency
This change implements the collection CatalogCache on top of the ReadThroughCache, giving it the ability to support causal consistency. As part of this change, the 'forceRefreshFromThisThread' flag has been removed from the shard's refresh methods. Co-authored-by: Tommaso Tocci <tommaso.tocci@mongodb.com> Co-authored-by: Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> Co-authored-by: Kaloian Manassiev <kaloian.manassiev@mongodb.com>
Diffstat (limited to 'src/mongo/s/commands')
-rw-r--r--src/mongo/s/commands/cluster_drop_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_merge_chunks_cmd.cpp6
-rw-r--r--src/mongo/s/commands/cluster_move_chunk_cmd.cpp11
-rw-r--r--src/mongo/s/commands/cluster_shard_collection_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_split_cmd.cpp6
-rw-r--r--src/mongo/s/commands/flush_router_config_cmd.cpp2
-rw-r--r--src/mongo/s/commands/strategy.cpp16
7 files changed, 27 insertions, 22 deletions
diff --git a/src/mongo/s/commands/cluster_drop_cmd.cpp b/src/mongo/s/commands/cluster_drop_cmd.cpp
index a69e3292597..f727489ccc0 100644
--- a/src/mongo/s/commands/cluster_drop_cmd.cpp
+++ b/src/mongo/s/commands/cluster_drop_cmd.cpp
@@ -88,7 +88,9 @@ public:
// Invalidate the routing table cache entry for this collection so that we reload it the
// next time it is accessed, even if sending the command to the config server fails due
// to e.g. a NetworkError.
- ON_BLOCK_EXIT([opCtx, nss] { Grid::get(opCtx)->catalogCache()->onEpochChange(nss); });
+ ON_BLOCK_EXIT([opCtx, nss] {
+ Grid::get(opCtx)->catalogCache()->invalidateCollectionEntry_LINEARIZABLE(nss);
+ });
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
diff --git a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp
index b4157bee9d9..531aa1ab41e 100644
--- a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp
+++ b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp
@@ -174,8 +174,10 @@ public:
Shard::RetryPolicy::kNotIdempotent));
uassertStatusOK(response.commandStatus);
- Grid::get(opCtx)->catalogCache()->invalidateShardForShardedCollection(
- nss, firstChunk.getShardId());
+ Grid::get(opCtx)
+ ->catalogCache()
+ ->invalidateShardOrEntireCollectionEntryForShardedCollection(
+ nss, boost::none, firstChunk.getShardId());
CommandHelpers::filterCommandReplyForPassthrough(response.response, &result);
return true;
diff --git a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp
index 01cdb91234e..f6e2d27c80f 100644
--- a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp
+++ b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp
@@ -198,9 +198,14 @@ public:
cmdObj["waitForDelete"].trueValue(),
forceJumbo));
- Grid::get(opCtx)->catalogCache()->invalidateShardForShardedCollection(nss,
- chunk->getShardId());
- Grid::get(opCtx)->catalogCache()->invalidateShardForShardedCollection(nss, to->getId());
+ Grid::get(opCtx)
+ ->catalogCache()
+ ->invalidateShardOrEntireCollectionEntryForShardedCollection(
+ nss, boost::none, chunk->getShardId());
+ Grid::get(opCtx)
+ ->catalogCache()
+ ->invalidateShardOrEntireCollectionEntryForShardedCollection(
+ nss, boost::none, to->getId());
result.append("millis", t.millis());
return true;
diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
index d27fd037d30..d4c4d7901ad 100644
--- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
+++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
@@ -105,7 +105,9 @@ public:
// Invalidate the routing table cache entry for this collection so that we reload the
// collection the next time it's accessed, even if we receive a failure, e.g. NetworkError.
- ON_BLOCK_EXIT([opCtx, nss] { Grid::get(opCtx)->catalogCache()->onEpochChange(nss); });
+ ON_BLOCK_EXIT([opCtx, nss] {
+ Grid::get(opCtx)->catalogCache()->invalidateCollectionEntry_LINEARIZABLE(nss);
+ });
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
diff --git a/src/mongo/s/commands/cluster_split_cmd.cpp b/src/mongo/s/commands/cluster_split_cmd.cpp
index 19d33b3f10b..5532fac1daf 100644
--- a/src/mongo/s/commands/cluster_split_cmd.cpp
+++ b/src/mongo/s/commands/cluster_split_cmd.cpp
@@ -270,8 +270,10 @@ public:
ChunkRange(chunk->getMin(), chunk->getMax()),
{splitPoint}));
- Grid::get(opCtx)->catalogCache()->invalidateShardForShardedCollection(nss,
- chunk->getShardId());
+ Grid::get(opCtx)
+ ->catalogCache()
+ ->invalidateShardOrEntireCollectionEntryForShardedCollection(
+ nss, boost::none, chunk->getShardId());
return true;
}
diff --git a/src/mongo/s/commands/flush_router_config_cmd.cpp b/src/mongo/s/commands/flush_router_config_cmd.cpp
index bcc61a82a0a..d27b65a2c4d 100644
--- a/src/mongo/s/commands/flush_router_config_cmd.cpp
+++ b/src/mongo/s/commands/flush_router_config_cmd.cpp
@@ -102,7 +102,7 @@ public:
"Routing metadata flushed for collection {namespace}",
"Routing metadata flushed for collection",
"namespace"_attr = nss);
- catalogCache->purgeCollection(nss);
+ catalogCache->invalidateCollectionEntry_LINEARIZABLE(nss);
}
}
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 644c10e6bcb..f83b490d0ef 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -722,16 +722,12 @@ void runCommand(OperationContext* opCtx,
auto catalogCache = Grid::get(opCtx)->catalogCache();
if (auto staleInfo = ex.extraInfo<StaleConfigInfo>()) {
catalogCache->invalidateShardOrEntireCollectionEntryForShardedCollection(
- opCtx,
- staleNs,
- staleInfo->getVersionWanted(),
- staleInfo->getVersionReceived(),
- staleInfo->getShardId());
+ staleNs, staleInfo->getVersionWanted(), staleInfo->getShardId());
} else {
// If we don't have the stale config info and therefore don't know the shard's
// id, we have to force all further targetting requests for the namespace to
// block on a refresh.
- catalogCache->onEpochChange(staleNs);
+ catalogCache->invalidateCollectionEntry_LINEARIZABLE(staleNs);
}
@@ -1301,16 +1297,12 @@ void Strategy::explainFind(OperationContext* opCtx,
Grid::get(opCtx)
->catalogCache()
->invalidateShardOrEntireCollectionEntryForShardedCollection(
- opCtx,
- staleNs,
- staleInfo->getVersionWanted(),
- staleInfo->getVersionReceived(),
- staleInfo->getShardId());
+ staleNs, staleInfo->getVersionWanted(), staleInfo->getShardId());
} else {
// If we don't have the stale config info and therefore don't know the shard's id,
// we have to force all further targetting requests for the namespace to block on
// a refresh.
- Grid::get(opCtx)->catalogCache()->onEpochChange(staleNs);
+ Grid::get(opCtx)->catalogCache()->invalidateCollectionEntry_LINEARIZABLE(staleNs);
}
if (canRetry) {