diff options
author | Dan Larkin-York <dan.larkin-york@mongodb.com> | 2022-12-02 13:22:14 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-12-02 14:53:16 +0000 |
commit | 31be4c38188fd14a6bd80753999236801f0a03a6 (patch) | |
tree | ef046449c6524f0a3c7bc04dd864dcdec4e4f087 | |
parent | 1bca0707395f0f8d61a7ab6414f743ac47367ce2 (diff) | |
download | mongo-31be4c38188fd14a6bd80753999236801f0a03a6.tar.gz |
SERVER-71719 Check if we have bucket to reopen before calling rehydrateBucket
-rw-r--r-- | src/mongo/db/timeseries/bucket_catalog.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/timeseries/bucket_catalog.h | 3 |
2 files changed, 6 insertions, 12 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp index 492d344f84f..3c4ca40c2dc 100644 --- a/src/mongo/db/timeseries/bucket_catalog.cpp +++ b/src/mongo/db/timeseries/bucket_catalog.cpp @@ -904,7 +904,6 @@ Status BucketCatalog::reopenBucket(OperationContext* opCtx, ns, coll->getDefaultCollator(), *options, - stats, BucketToReopen{bucketDoc, validator}, boost::none); if (!res.isOK()) { @@ -1391,16 +1390,11 @@ StatusWith<std::unique_ptr<BucketCatalog::Bucket>> BucketCatalog::_rehydrateBuck const NamespaceString& ns, const StringData::ComparatorInterface* comparator, const TimeseriesOptions& options, - ExecutionStatsController stats, - boost::optional<BucketToReopen> bucketToReopen, + const BucketToReopen& bucketToReopen, boost::optional<const BucketKey&> expectedKey) { - if (!bucketToReopen) { - // Nothing to rehydrate. - return {ErrorCodes::BadValue, "No bucket to rehydrate"}; - } invariant(feature_flags::gTimeseriesScalabilityImprovements.isEnabled( serverGlobalParams.featureCompatibility)); - const auto& [bucketDoc, validator, catalogEra] = bucketToReopen.value(); + const auto& [bucketDoc, validator, catalogEra] = bucketToReopen; if (catalogEra < _bucketStateManager.getEra()) { return {ErrorCodes::WriteConflict, "Bucket is from an earlier era, may be outdated"}; } @@ -1625,8 +1619,9 @@ StatusWith<BucketCatalog::InsertResult> BucketCatalog::_insert( CreationInfo info{key, stripeNumber, time, options, stats, &result.closedBuckets}; boost::optional<BucketToReopen> bucketToReopen = std::move(bucketFindResult.bucketToReopen); - auto rehydratedBucket = - _rehydrateBucket(opCtx, ns, comparator, options, stats, bucketToReopen, key); + auto rehydratedBucket = bucketToReopen.has_value() + ? _rehydrateBucket(opCtx, ns, comparator, options, bucketToReopen.value(), key) + : StatusWith<std::unique_ptr<Bucket>>{ErrorCodes::BadValue, "No bucket to rehydrate"}; if (rehydratedBucket.getStatus().code() == ErrorCodes::WriteConflict) { stats.incNumBucketReopeningsFailed(); return rehydratedBucket.getStatus(); diff --git a/src/mongo/db/timeseries/bucket_catalog.h b/src/mongo/db/timeseries/bucket_catalog.h index b25f2c1cded..5880ca39dff 100644 --- a/src/mongo/db/timeseries/bucket_catalog.h +++ b/src/mongo/db/timeseries/bucket_catalog.h @@ -972,8 +972,7 @@ protected: const NamespaceString& ns, const StringData::ComparatorInterface* comparator, const TimeseriesOptions& options, - ExecutionStatsController stats, - boost::optional<BucketToReopen> bucketToReopen, + const BucketToReopen& bucketToReopen, boost::optional<const BucketKey&> expectedKey); /** |