diff options
author | Eric Cox <eric.cox@mongodb.com> | 2021-08-02 21:58:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-12 14:12:19 +0000 |
commit | d63bbceedef055476559998b183f97f1ede8b49f (patch) | |
tree | fe0911131ccd0045ab0e1ee710998127acaf006d | |
parent | a5e2f9b0a236462a6d1ca129583c617f111367b4 (diff) | |
download | mongo-d63bbceedef055476559998b183f97f1ede8b49f.tar.gz |
SERVER-59044 Bailout early if a time series collection is empty when building a TrialStage
(cherry picked from commit bb6ec30bcbbb7b16f9f1c80cc3c9a99efcd5687c)
-rw-r--r-- | src/mongo/db/pipeline/pipeline_d.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp index dca31cd55b0..28c870d99d8 100644 --- a/src/mongo/db/pipeline/pipeline_d.cpp +++ b/src/mongo/db/pipeline/pipeline_d.cpp @@ -185,6 +185,16 @@ createRandomCursorExecutor(const CollectionPtr& coll, minAdvancedToWorkRatio); trialStage = static_cast<TrialStage*>(root.get()); } else if (expCtx->ns.isTimeseriesBucketsCollection()) { + // We can't take ARHASH optimization path for a direct $sample on the system.buckets + // collection because data is in compressed form. If we did have a direct $sample on the + // system.buckets collection, then the 'bucketUnpacker' would not be set up properly. We + // also should bail out early if a $sample is made against a time series collection that is + // empty. If we don't the 'minAdvancedToWorkRatio' can be nan/-nan depending on the + // architecture. + if (!(bucketUnpacker && numRecords)) { + return std::pair{nullptr, false}; + } + // Use a 'TrialStage' to run a trial between 'SampleFromTimeseriesBucket' and // 'UnpackTimeseriesBucket' with $sample left in the pipeline in-place. If the buckets are // not sufficiently full, or the 'SampleFromTimeseriesBucket' plan draws too many |