diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2019-10-21 18:06:53 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-21 18:06:53 +0000 |
commit | babc552483a0f8a2fff4c20354089b78da14baeb (patch) | |
tree | 0e452d1cacf751b36a70166b2771e3d6c4ac6737 | |
parent | 80d53a8378637e9c25a340b41928a7d28fa61dc3 (diff) | |
download | mongo-babc552483a0f8a2fff4c20354089b78da14baeb.tar.gz |
SERVER-42836 Count bytes in _totalDataSizeBytes after adding to Sorter
Before this patch, the bytes get added _before_ we add to the Sorter,
even though there is still a possibility that Sorter::add() will use
up the rest of its memory limit and throw.
-rw-r--r-- | src/mongo/db/exec/sort_executor.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mongo/db/exec/sort_executor.cpp b/src/mongo/db/exec/sort_executor.cpp index 5cc11e004b0..51e0255a01d 100644 --- a/src/mongo/db/exec/sort_executor.cpp +++ b/src/mongo/db/exec/sort_executor.cpp @@ -109,12 +109,12 @@ void SortExecutor::add(Value sortKey, WorkingSetMember data) { // Metadata should be attached directly to the WSM rather than inside the Document. invariant(!data.doc.value().metadata()); - _totalDataSizeBytes += data.getMemUsage(); - if (!_sorter) { _sorter.reset(DocumentSorter::make(makeSortOptions(), Comparator(_sortPattern))); } _sorter->add(std::move(sortKey), std::move(data)); + + _totalDataSizeBytes += data.getMemUsage(); } void SortExecutor::loadingDone() { |