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-06 16:19:41 +0000 |
commit | 9b96ed3f3395613af9d23a0dd7ba6ea7d08f8fe3 (patch) | |
tree | a6e7b1260df0ea3ac91f6f5e1ff75c9c11879e68 | |
parent | 9d78ef337bb3d87808775a631927f52ab126cf7f (diff) | |
download | mongo-9b96ed3f3395613af9d23a0dd7ba6ea7d08f8fe3.tar.gz |
SERVER-71719 Check if we have bucket to reopen before calling rehydrateBucket
(cherry picked from commit 31be4c38188fd14a6bd80753999236801f0a03a6)
-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 d7d07cb5c8c..1d25e6036a6 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"}; } @@ -1621,8 +1615,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 3497f568306..bc907eadccf 100644 --- a/src/mongo/db/timeseries/bucket_catalog.h +++ b/src/mongo/db/timeseries/bucket_catalog.h @@ -968,8 +968,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); /** |