summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.cpp
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2019-08-01 01:10:45 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2019-08-08 10:22:00 -0400
commit8457da2f81b5378fa7485a151cb2255700a6c31a (patch)
tree0a01c32672e8100db43d5beb414bfffcc3ae8316 /src/mongo/db/db_raii.cpp
parent70a987f5efd85c3162823e8a07f49566b10d2020 (diff)
downloadmongo-8457da2f81b5378fa7485a151cb2255700a6c31a.tar.gz
SERVER-42600 Implement the FCV 4.4 checkShardVersion protocol
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r--src/mongo/db/db_raii.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index c851fcfcc9c..854b02fbdf6 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -316,13 +316,13 @@ AutoGetCollectionForReadCommand::AutoGetCollectionForReadCommand(
_autoCollForRead.getDb() ? _autoCollForRead.getDb()->getProfilingLevel()
: kDoNotChangeProfilingLevel,
deadline) {
- if (!_autoCollForRead.getView()) {
- // Perform the check early so the query planner would be able to extract the correct
- // shard key. Also make sure that version is compatible if query planner decides to
- // use an empty plan.
- auto css = CollectionShardingState::get(opCtx, _autoCollForRead.getNss());
- css->checkShardVersionOrThrow(opCtx);
- }
+
+ // Perform the check early so the query planner would be able to extract the correct
+ // shard key. Also make sure that version is compatible if query planner decides to
+ // use an empty plan.
+ invariant(!_autoCollForRead.getView() || !_autoCollForRead.getCollection());
+ auto css = CollectionShardingState::get(opCtx, _autoCollForRead.getNss());
+ css->checkShardVersionOrThrow(opCtx, _autoCollForRead.getCollection());
}
OldClientContext::OldClientContext(OperationContext* opCtx, const std::string& ns, bool doVersion)
@@ -344,7 +344,8 @@ OldClientContext::OldClientContext(OperationContext* opCtx, const std::string& n
break;
default:
CollectionShardingState::get(_opCtx, NamespaceString(ns))
- ->checkShardVersionOrThrow(_opCtx);
+ ->checkShardVersionOrThrow(_opCtx,
+ _db->getCollection(opCtx, NamespaceString(ns)));
break;
}
}