summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Seyster <justin.seyster@mongodb.com>2019-11-18 17:46:25 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-02 18:10:46 +0000
commit2606b8fd4a045a27acc7d57f08d5fc6f51d31296 (patch)
treeb80afb1af9794a206bdfe6b97ce620c489b925ad /src
parent5a3dd86b2e06a065ba435e4a6fe69300d0ba73a0 (diff)
downloadmongo-2606b8fd4a045a27acc7d57f08d5fc6f51d31296.tar.gz
SERVER-46109 Adopt QueryExceededMemoryLimitNoDiskUseAllowed error code
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/document_source_bucket_auto_test.cpp8
-rw-r--r--src/mongo/db/pipeline/document_source_group.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_group_test.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_sort_test.cpp6
-rw-r--r--src/mongo/db/sorter/sorter.cpp19
5 files changed, 24 insertions, 17 deletions
diff --git a/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp b/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp
index b7b50b6527d..c6dcf05e1ea 100644
--- a/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp
+++ b/src/mongo/db/pipeline/document_source_bucket_auto_test.cpp
@@ -644,7 +644,9 @@ void assertCannotSpillToDisk(const boost::intrusive_ptr<ExpressionContext>& expC
{Document{{"a", 0}, {"largeStr", largeStr}}, Document{{"a", 1}, {"largeStr", largeStr}}});
bucketAutoStage->setSource(mock.get());
- ASSERT_THROWS_CODE(bucketAutoStage->getNext(), AssertionException, 16819);
+ ASSERT_THROWS_CODE(bucketAutoStage->getNext(),
+ AssertionException,
+ ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed);
}
TEST_F(BucketAutoTests, ShouldFailIfBufferingTooManyDocuments) {
@@ -687,7 +689,9 @@ TEST_F(BucketAutoTests, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
ASSERT_TRUE(bucketAutoStage->getNext().isPaused());
// The next should realize it's used too much memory.
- ASSERT_THROWS_CODE(bucketAutoStage->getNext(), AssertionException, 16819);
+ ASSERT_THROWS_CODE(bucketAutoStage->getNext(),
+ AssertionException,
+ ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed);
}
TEST_F(BucketAutoTests, ShouldRoundUpMaximumBoundariesWithGranularitySpecified) {
diff --git a/src/mongo/db/pipeline/document_source_group.cpp b/src/mongo/db/pipeline/document_source_group.cpp
index 8268f0a1dd1..230162d2f51 100644
--- a/src/mongo/db/pipeline/document_source_group.cpp
+++ b/src/mongo/db/pipeline/document_source_group.cpp
@@ -483,7 +483,7 @@ DocumentSource::GetNextResult DocumentSourceGroup::initialize() {
GetNextResult input = pSource->getNext();
for (; input.isAdvanced(); input = pSource->getNext()) {
if (_memoryUsageBytes > _maxMemoryUsageBytes) {
- uassert(16945,
+ uassert(ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed,
"Exceeded memory limit for $group, but didn't allow external sort."
" Pass allowDiskUse:true to opt in.",
_allowDiskUse);
diff --git a/src/mongo/db/pipeline/document_source_group_test.cpp b/src/mongo/db/pipeline/document_source_group_test.cpp
index c3c764c4f6a..0289195c878 100644
--- a/src/mongo/db/pipeline/document_source_group_test.cpp
+++ b/src/mongo/db/pipeline/document_source_group_test.cpp
@@ -166,7 +166,8 @@ TEST_F(DocumentSourceGroupTest, ShouldErrorIfNotAllowedToSpillToDiskAndResultSet
Document{{"_id", 1}, {"largeStr", largeStr}}});
group->setSource(mock.get());
- ASSERT_THROWS_CODE(group->getNext(), AssertionException, 16945);
+ ASSERT_THROWS_CODE(
+ group->getNext(), AssertionException, ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed);
}
TEST_F(DocumentSourceGroupTest, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
@@ -197,7 +198,8 @@ TEST_F(DocumentSourceGroupTest, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
ASSERT_TRUE(group->getNext().isPaused());
// The next should realize it's used too much memory.
- ASSERT_THROWS_CODE(group->getNext(), AssertionException, 16945);
+ ASSERT_THROWS_CODE(
+ group->getNext(), AssertionException, ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed);
}
TEST_F(DocumentSourceGroupTest, ShouldReportSingleFieldGroupKeyAsARename) {
diff --git a/src/mongo/db/pipeline/document_source_sort_test.cpp b/src/mongo/db/pipeline/document_source_sort_test.cpp
index fc7011c03a3..4e1ee295924 100644
--- a/src/mongo/db/pipeline/document_source_sort_test.cpp
+++ b/src/mongo/db/pipeline/document_source_sort_test.cpp
@@ -443,7 +443,8 @@ TEST_F(DocumentSourceSortExecutionTest,
Document{{"_id", 1}, {"largeStr", largeStr}}});
sort->setSource(mock.get());
- ASSERT_THROWS_CODE(sort->getNext(), AssertionException, 16819);
+ ASSERT_THROWS_CODE(
+ sort->getNext(), AssertionException, ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed);
}
TEST_F(DocumentSourceSortExecutionTest, ShouldCorrectlyTrackMemoryUsageBetweenPauses) {
@@ -465,7 +466,8 @@ TEST_F(DocumentSourceSortExecutionTest, ShouldCorrectlyTrackMemoryUsageBetweenPa
ASSERT_TRUE(sort->getNext().isPaused());
// The next should realize it's used too much memory.
- ASSERT_THROWS_CODE(sort->getNext(), AssertionException, 16819);
+ ASSERT_THROWS_CODE(
+ sort->getNext(), AssertionException, ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed);
}
} // namespace
diff --git a/src/mongo/db/sorter/sorter.cpp b/src/mongo/db/sorter/sorter.cpp
index 41675b140df..aa387dcb944 100644
--- a/src/mongo/db/sorter/sorter.cpp
+++ b/src/mongo/db/sorter/sorter.cpp
@@ -595,11 +595,11 @@ private:
return;
if (!_opts.extSortAllowed) {
- // XXX This error message is only correct for aggregation, but it is also the
- // only way this code could be hit at the moment. If the Sorter is used
- // elsewhere where extSortAllowed could possibly be false, this message will
- // need to be revisited.
- uasserted(16819,
+ // This error message only applies to sorts from user queries made through the find or
+ // aggregation commands. Other clients, such as bulk index builds, should suppress this
+ // error, either by allowing external sorting or by catching and throwing a more
+ // appropriate error.
+ uasserted(ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed,
str::stream() << "Sort exceeded memory limit of " << _opts.maxMemoryUsageBytes
<< " bytes, but did not opt in to external sorting.");
}
@@ -880,11 +880,10 @@ private:
return;
if (!_opts.extSortAllowed) {
- // XXX This error message is only correct for aggregation, but it is also the
- // only way this code could be hit at the moment. If the Sorter is used
- // elsewhere where extSortAllowed could possibly be false, this message will
- // need to be revisited.
- uasserted(16820,
+ // This error message only applies to sorts from user queries made through the find or
+ // aggregation commands. Other clients should suppress this error, either by allowing
+ // external sorting or by catching and throwing a more appropriate error.
+ uasserted(ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed,
str::stream()
<< "Sort exceeded memory limit of " << _opts.maxMemoryUsageBytes
<< " bytes, but did not opt in to external sorting. Aborting operation."