summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMatt Boros <matt.boros@mongodb.com>2022-08-11 14:45:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-12 19:54:20 +0000
commita0eeb88ef210a2287697342781f488fd1935dad0 (patch)
treeb1e24441a51f76844c835cc7c065e88b801c20c7 /src/mongo
parent4343f51e2359477b43666db100b573c5cf5dd357 (diff)
downloadmongo-a0eeb88ef210a2287697342781f488fd1935dad0.tar.gz
SERVER-68501 changed invariant to uassert for direct bounded sort use
(cherry picked from commit 1f93d126c0e83ca6de5dfa08648b1f61e90b04e1)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/exec/document_value/document_metadata_fields.h8
-rw-r--r--src/mongo/db/exec/document_value/document_metadata_fields_test.cpp29
-rw-r--r--src/mongo/db/pipeline/document_source_sort.cpp7
3 files changed, 40 insertions, 4 deletions
diff --git a/src/mongo/db/exec/document_value/document_metadata_fields.h b/src/mongo/db/exec/document_value/document_metadata_fields.h
index 12932c29686..c3541ced659 100644
--- a/src/mongo/db/exec/document_value/document_metadata_fields.h
+++ b/src/mongo/db/exec/document_value/document_metadata_fields.h
@@ -327,7 +327,9 @@ public:
}
Date_t getTimeseriesBucketMinTime() const {
- invariant(hasTimeseriesBucketMinTime());
+ tassert(6850100,
+ "Document must have timeseries bucket min time metadata field set",
+ hasTimeseriesBucketMinTime());
return _holder->timeseriesBucketMinTime;
}
@@ -344,7 +346,9 @@ public:
}
Date_t getTimeseriesBucketMaxTime() const {
- invariant(hasTimeseriesBucketMaxTime());
+ tassert(6850101,
+ "Document must have timeseries bucket max time metadata field set",
+ hasTimeseriesBucketMaxTime());
return _holder->timeseriesBucketMaxTime;
}
diff --git a/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp b/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp
index 5515009b2bd..16dd8a5b558 100644
--- a/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp
+++ b/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/exec/document_value/document_metadata_fields.h"
#include "mongo/db/exec/document_value/document_value_test_util.h"
#include "mongo/unittest/bson_test_util.h"
+#include "mongo/unittest/death_test.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -268,4 +269,32 @@ TEST(DocumentMetadataFieldsTest, CopyFromCopiesAllMetadataThatSourceHas) {
ASSERT_FALSE(destination.hasSearchScoreDetails());
}
+TEST(DocumentMetadataFieldsTest, GetTimeseriesBucketMinTimeExists) {
+ DocumentMetadataFields source;
+ Date_t time;
+ source.setTimeseriesBucketMinTime(time);
+ ASSERT_EQ(source.getTimeseriesBucketMinTime(), time);
+}
+
+TEST(DocumentMetadataFieldsTest, GetTimeseriesBucketMaxTimeExists) {
+ DocumentMetadataFields source;
+ Date_t time;
+ source.setTimeseriesBucketMaxTime(time);
+ ASSERT_EQ(source.getTimeseriesBucketMaxTime(), time);
+}
+
+DEATH_TEST_REGEX(DocumentMetadataFieldsTest,
+ GetTimeseriesBucketMinTimeDoesntExist,
+ "Tripwire assertion.*6850100") {
+ DocumentMetadataFields source;
+ source.getTimeseriesBucketMinTime();
+}
+
+DEATH_TEST_REGEX(DocumentMetadataFieldsTest,
+ GetTimeseriesBucketMaxTimeDoesntExist,
+ "Tripwire assertion.*6850101") {
+ DocumentMetadataFields source;
+ source.getTimeseriesBucketMaxTime();
+}
+
} // namespace mongo
diff --git a/src/mongo/db/pipeline/document_source_sort.cpp b/src/mongo/db/pipeline/document_source_sort.cpp
index 2c07c43c501..1ccc8a5d58d 100644
--- a/src/mongo/db/pipeline/document_source_sort.cpp
+++ b/src/mongo/db/pipeline/document_source_sort.cpp
@@ -142,12 +142,15 @@ REGISTER_DOCUMENT_SOURCE(sort,
LiteParsedDocumentSourceDefault::parse,
DocumentSourceSort::createFromBson,
AllowedWithApiStrict::kAlways);
+
REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
_internalBoundedSort,
LiteParsedDocumentSourceDefault::parse,
DocumentSourceSort::parseBoundedSort,
- AllowedWithApiStrict::kNeverInVersion1,
- AllowedWithClientType::kAny,
+ ::mongo::getTestCommandsEnabled() ? AllowedWithApiStrict::kNeverInVersion1
+ : AllowedWithApiStrict::kInternal,
+ ::mongo::getTestCommandsEnabled() ? AllowedWithClientType::kAny
+ : AllowedWithClientType::kInternal,
feature_flags::gFeatureFlagBucketUnpackWithSort.getVersion(),
feature_flags::gFeatureFlagBucketUnpackWithSort.isEnabledAndIgnoreFCV());