diff options
author | Rushan Chen <rushan.chen@mongodb.com> | 2023-01-11 11:58:28 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-11 12:33:37 +0000 |
commit | 37bbca32d5adc3654dff73b94816a7bd56cd9d42 (patch) | |
tree | f8f7bcb6b6f2e2d70a07b545363a75f62a2b47b1 /src/mongo | |
parent | 6cf2a3f731b730a5562a507ed064edc4f86c67e2 (diff) | |
download | mongo-37bbca32d5adc3654dff73b94816a7bd56cd9d42.tar.gz |
SERVER-70445 check existence of TimeseriesOptions before using the time series bucket collection name space
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); |