diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands/write_commands.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/service_entry_point_common.cpp | 10 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/mongo/db/commands/write_commands.cpp b/src/mongo/db/commands/write_commands.cpp index 15dfa5a7b4c..f1068f91a34 100644 --- a/src/mongo/db/commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands.cpp @@ -146,9 +146,8 @@ bool isTimeseries(OperationContext* opCtx, const Request& request) { // collection does not yet exist, this check may return false unnecessarily. As a result, an // insert attempt into the time-series namespace will either succeed or fail, depending on who // wins the race. - return CollectionCatalog::get(opCtx) - ->lookupCollectionByNamespaceForRead(opCtx, bucketNss) - .get(); + auto coll = CollectionCatalog::get(opCtx)->lookupCollectionByNamespaceForRead(opCtx, bucketNss); + return (coll && coll->getTimeseriesOptions()); } NamespaceString makeTimeseriesBucketsNamespace(const NamespaceString& nss) { diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index d4b0c5b99fc..091d4d80d39 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -1708,12 +1708,10 @@ void ExecCommandDatabase::_initiateCommand() { // possible that a stale mongos may send the request over a view namespace. In this case, we // initialize the 'OperationShardingState' with buckets namespace. auto bucketNss = _invocation->ns().makeTimeseriesBucketsNamespace(); - auto namespaceForSharding = CollectionCatalog::get(opCtx) - ->lookupCollectionByNamespaceForRead(opCtx, bucketNss) - .get() - ? bucketNss - : _invocation->ns(); - + auto coll = + CollectionCatalog::get(opCtx)->lookupCollectionByNamespaceForRead(opCtx, bucketNss); + auto namespaceForSharding = + (coll && coll->getTimeseriesOptions()) ? bucketNss : _invocation->ns(); boost::optional<ShardVersion> shardVersion; if (auto shardVersionElem = request.body[ShardVersion::kShardVersionField]) { shardVersion = ShardVersion::parse(shardVersionElem); |