diff options
| author | Dan Larkin-York <dan.larkin-york@mongodb.com> | 2023-07-26 22:08:44 +0000 |
|---|---|---|
| committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-07-27 00:54:37 +0000 |
| commit | 0d1635d51d552e1d69dfc6da25b5f0488348d62e (patch) | |
| tree | 0702a48bdfb1d7c2e2dbf8a34bc7cffb350906ad | |
| parent | 15dadd75e65169698fb1751c29096cd5322dbcc8 (diff) | |
Revert "SERVER-78950 Use sequential time series bucket IDs when possible"r7.0.0-rc10
This reverts commit e8662106357ca486ac26252562058a796ad2403e.
4 files changed, 7 insertions, 32 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp index 0868b9264a1..22a1ba0abba 100644 --- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp +++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp @@ -369,10 +369,6 @@ void clear(BucketCatalog& catalog, StringData dbName) { }); } -void resetBucketOIDCounter() { - internal::resetBucketOIDCounter(); -} - void appendExecutionStats(const BucketCatalog& catalog, const NamespaceString& ns, BSONObjBuilder& builder) { diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h index 141c13d334b..b66a7c4e264 100644 --- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h +++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h @@ -266,11 +266,6 @@ void clear(BucketCatalog& catalog, const NamespaceString& ns); void clear(BucketCatalog& catalog, StringData dbName); /** - * Resets the counter used for bucket OID generation. Should be called after a bucket _id collision. - */ -void resetBucketOIDCounter(); - -/** * Appends the execution stats for the given namespace to the builder. */ void appendExecutionStats(const BucketCatalog& catalog, diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.cpp b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.cpp index 53d46946fe0..a61a1ed17f2 100644 --- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.cpp +++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.cpp @@ -47,7 +47,6 @@ MONGO_FAIL_POINT_DEFINE(hangWaitingForConflictingPreparedBatch); Mutex _bucketIdGenLock = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "bucket_catalog_internal::_bucketIdGenLock"); PseudoRandom _bucketIdGenPRNG(SecureRandom().nextInt64()); -AtomicWord<uint64_t> _bucketIdGenCounter{static_cast<uint64_t>(_bucketIdGenPRNG.nextInt64())}; OperationId getOpId(OperationContext* opCtx, CombineWithInsertsFromOtherClients combine) { switch (combine) { @@ -1088,28 +1087,21 @@ std::pair<OID, Date_t> generateBucketOID(const Date_t& time, const TimeseriesOpt // paradox converges to roughly the square root of the size of the space, so we would need a few // billion buckets with the same timestamp to expect collisions. In the rare case that we do get // a collision, we can (and do) simply regenerate the bucket _id at a higher level. - uint64_t bits = BigEndian<uint64_t>::store(_bucketIdGenCounter.addAndFetch(1)); - OID::InstanceUnique instance; - const auto instanceBuf = static_cast<uint8_t*>(instance.bytes); - std::memcpy(instanceBuf, &bits, OID::kInstanceUniqueSize); - OID::Increment increment; - const auto incrementBuf = static_cast<uint8_t*>(increment.bytes); - uint8_t* bitsBuf = (uint8_t*)&bits; - std::memcpy(incrementBuf, &(bitsBuf)[OID::kInstanceUniqueSize], OID::kIncrementSize); - + { + // We need to serialize access to '_bucketIdGenPRNG' since this instance is shared between + // all bucket_catalog operations, and not protected by the catalog or stripe locks. + stdx::unique_lock lk{_bucketIdGenLock}; + _bucketIdGenPRNG.fill(instance.bytes, OID::kInstanceUniqueSize); + _bucketIdGenPRNG.fill(increment.bytes, OID::kIncrementSize); + } oid.setInstanceUnique(instance); oid.setIncrement(increment); return {oid, roundedTime}; } -void resetBucketOIDCounter() { - stdx::lock_guard lk{_bucketIdGenLock}; - _bucketIdGenCounter.store(static_cast<uint64_t>(_bucketIdGenPRNG.nextInt64())); -} - Bucket& allocateBucket(BucketCatalog& catalog, Stripe& stripe, WithLock stripeLock, @@ -1134,9 +1126,6 @@ Bucket& allocateBucket(BucketCatalog& catalog, info.options.getTimeField(), roundedTime, catalog.bucketStateRegistry)); - if (!inserted) { - resetBucketOIDCounter(); - } } uassert(6130900, "Unable to insert documents due to internal OID generation collision. Increase the " diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.h b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.h index 99f6169a1a9..ff3a6e9121e 100644 --- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.h +++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_internal.h @@ -295,11 +295,6 @@ void expireIdleBuckets(BucketCatalog& catalog, std::pair<OID, Date_t> generateBucketOID(const Date_t& time, const TimeseriesOptions& options); /** - * Resets the counter used for bucket OID generation. Should be called after a collision. - */ -void resetBucketOIDCounter(); - -/** * Allocates a new bucket and adds it to the catalog. */ Bucket& allocateBucket(BucketCatalog& catalog, |
