From 06cb81be3d860f67b8f26c3b988c6748f5ef7f89 Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Tue, 26 Nov 2019 10:13:52 +0100 Subject: [PATCH] Bug fix 3.4/little weekend fix (#10526) * create arena before using it * try to avoid oom situation --- arangod/MMFiles/MMFilesHashIndex.cpp | 1 + arangod/MMFiles/MMFilesHashIndex.h | 6 ++++-- arangod/MMFiles/MMFilesPrimaryIndex.cpp | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arangod/MMFiles/MMFilesHashIndex.cpp b/arangod/MMFiles/MMFilesHashIndex.cpp index 559fab30ca..a0fa5923de 100644 --- a/arangod/MMFiles/MMFilesHashIndex.cpp +++ b/arangod/MMFiles/MMFilesHashIndex.cpp @@ -52,6 +52,7 @@ MMFilesHashIndexLookupBuilder::MMFilesHashIndexLookupBuilder( : _builder(trx), _usesIn(false), _isEmpty(false), + _mappingFieldConditionArena(), _mappingFieldCondition{_mappingFieldConditionArena}, _inStorage(trx) { TRI_ASSERT(node->type == aql::NODE_TYPE_OPERATOR_NARY_AND); diff --git a/arangod/MMFiles/MMFilesHashIndex.h b/arangod/MMFiles/MMFilesHashIndex.h index 5ec364f3e3..00f0ea24a5 100644 --- a/arangod/MMFiles/MMFilesHashIndex.h +++ b/arangod/MMFiles/MMFilesHashIndex.h @@ -179,8 +179,10 @@ class MMFilesHashIndexLookupBuilder { bool _isEmpty; size_t _coveredFields; - SmallVector _mappingFieldCondition; - SmallVector::allocator_type::arena_type _mappingFieldConditionArena; + using MappingCondition = + SmallVector; + MappingCondition::allocator_type::arena_type _mappingFieldConditionArena; + MappingCondition _mappingFieldCondition; std::unordered_map>> _inPosition; transaction::BuilderLeaser _inStorage; diff --git a/arangod/MMFiles/MMFilesPrimaryIndex.cpp b/arangod/MMFiles/MMFilesPrimaryIndex.cpp index 7875dce72b..87aaeaa042 100644 --- a/arangod/MMFiles/MMFilesPrimaryIndex.cpp +++ b/arangod/MMFiles/MMFilesPrimaryIndex.cpp @@ -21,8 +21,11 @@ /// @author Dr. Frank Celler //////////////////////////////////////////////////////////////////////////////// +#include + #include "MMFilesPrimaryIndex.h" #include "Aql/AstNode.h" +#include "Aql/ExecutionBlock.h" #include "Basics/Exceptions.h" #include "Basics/StaticStrings.h" #include "Basics/hashes.h" @@ -162,7 +165,7 @@ bool MMFilesAllIndexIterator::next(LocalDocumentIdCallback const& cb, size_t lim bool MMFilesAllIndexIterator::nextDocument(DocumentCallback const& cb, size_t limit) { _documentIds.clear(); - _documentIds.reserve(limit); + _documentIds.reserve((std::min)(limit, aql::ExecutionBlock::DefaultBatchSize())); bool done = false; while (limit > 0) {