From 66d62e802b3e952b73daf61545fd31158f198189 Mon Sep 17 00:00:00 2001 From: Yuhong Zhang <34732434+YuhongZhang98@users.noreply.github.com> Date: Thu, 9 Feb 2023 22:07:28 +0000 Subject: SERVER-73830 Handle buckets pending direct writes when retrieving alternate buckets --- .../db/timeseries/bucket_catalog/bucket_catalog.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp index 4019e73df3d..57c569e7d31 100644 --- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp +++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp @@ -746,15 +746,15 @@ Bucket* BucketCatalog::_useAlternateBucket(Stripe* stripe, return potentialBucket; } - // If we still have an entry for the bucket in the open set, but it conflicts with - // insertion, then it must have been cleared, and we can clean it up. - invariant(state.value().isSet(BucketStateFlag::kCleared)); - _abort(stripe, - stripeLock, - potentialBucket, - nullptr, - getTimeseriesBucketClearedError(potentialBucket->bucketId.ns, - potentialBucket->bucketId.oid)); + // Clean up the bucket if it has been cleared. + if (state.value().isSet(BucketStateFlag::kCleared)) { + _abort(stripe, + stripeLock, + potentialBucket, + nullptr, + getTimeseriesBucketClearedError(potentialBucket->bucketId.ns, + potentialBucket->bucketId.oid)); + } } return nullptr; -- cgit v1.2.1