diff options
author | Yuhong Zhang <yuhong.zhang@mongodb.com> | 2023-05-15 20:11:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-16 19:41:57 +0000 |
commit | 9067d947c9c75146ea889f334e5c5cd17e94baba (patch) | |
tree | 514aecf8108f2f0185c0791d21298fbfbc10bd42 /src/mongo/db/timeseries/bucket_catalog/bucket_catalog_test.cpp | |
parent | 2dfb0409715bfc35e12d7622e1c6e0a4727db1aa (diff) | |
download | mongo-9067d947c9c75146ea889f334e5c5cd17e94baba.tar.gz |
SERVER-77151 Make the number of stripes configurable for the bucket catalog
Diffstat (limited to 'src/mongo/db/timeseries/bucket_catalog/bucket_catalog_test.cpp')
-rw-r--r-- | src/mongo/db/timeseries/bucket_catalog/bucket_catalog_test.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_test.cpp b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_test.cpp index a0d5e879773..4e16dd68ba3 100644 --- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_test.cpp +++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog_test.cpp @@ -272,7 +272,7 @@ Status BucketCatalogTest::_reopenBucket(const CollectionPtr& coll, const BSONObj } auto bucket = std::move(res.getValue()); - auto stripeNumber = internal::getStripeNumber(key); + auto stripeNumber = internal::getStripeNumber(key, _bucketCatalog->numberOfStripes); // Register the reopened bucket with the catalog. auto& stripe = _bucketCatalog->stripes[stripeNumber]; @@ -395,6 +395,44 @@ TEST_F(BucketCatalogTest, InsertIntoDifferentBuckets) { } } +TEST_F(BucketCatalogTest, InsertThroughDifferentCatalogsIntoDifferentBuckets) { + BucketCatalog temporaryBucketCatalog(/*numberOfStripes=*/1); + auto result1 = insert(_opCtx, + *_bucketCatalog, + _ns1, + _getCollator(_ns1), + _getTimeseriesOptions(_ns1), + BSON(_timeField << Date_t::now()), + CombineWithInsertsFromOtherClients::kAllow); + auto batch1 = result1.getValue().batch; + auto result2 = insert(_opCtx, + temporaryBucketCatalog, + _ns1, + _getCollator(_ns1), + _getTimeseriesOptions(_ns1), + BSON(_timeField << Date_t::now()), + CombineWithInsertsFromOtherClients::kAllow); + auto batch2 = result2.getValue().batch; + + // Inserts should be into different buckets (and therefore batches) because they went through + // different bucket catalogs. + ASSERT_NE(batch1, batch2); + + // Committing one bucket should only return the one document in that bucket and should not + // affect the other bucket. + ASSERT(claimWriteBatchCommitRights(*batch1)); + ASSERT_OK(prepareCommit(*_bucketCatalog, batch1)); + ASSERT_EQ(batch1->measurements.size(), 1); + ASSERT_EQ(batch1->numPreviouslyCommittedMeasurements, 0); + finish(*_bucketCatalog, batch1, {}); + + ASSERT(claimWriteBatchCommitRights(*batch2)); + ASSERT_OK(prepareCommit(temporaryBucketCatalog, batch2)); + ASSERT_EQ(batch2->measurements.size(), 1); + ASSERT_EQ(batch2->numPreviouslyCommittedMeasurements, 0); + finish(temporaryBucketCatalog, batch2, {}); +} + TEST_F(BucketCatalogTest, InsertIntoSameBucketArray) { auto result1 = insert( _opCtx, |