Skip to content

Commit

Permalink
Fix bulk action OOME (MID-4479)
Browse files Browse the repository at this point in the history
Existing behavior (quite counter-intuitive) is that when having
search.scriptingExpression in bulk actions, results of individual
evaluations of that expression are ultimately collected into output
pipeline - which can consume a lot of memory. Introduced
"aggregateOutput" parameter that can turn this off.

(cherry picked from commit 1a9cd39)
  • Loading branch information
mederly committed Feb 28, 2018
1 parent a23b294 commit 72f79ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -314,6 +314,18 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="aggregateOutput" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Whether to aggregate and pass forward the output of expression evaluations that are done
for each object found. (Meaningful only if scriptingExpression is specified.)
Default is true for compatibility reasons. Set to false to optimize memory consumption.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.7.1</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Expand Down
Expand Up @@ -44,6 +44,7 @@
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.SearchExpressionType;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang.mutable.MutableBoolean;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -137,9 +138,12 @@ public <T extends ObjectType> PipelineData evaluate(SearchExpressionType searchE
}
JAXBElement<?> childExpression = searchExpression.getScriptingExpression();
try {
outputData.addAllFrom(scriptingExpressionEvaluator.evaluateExpression(
PipelineData expressionResult = scriptingExpressionEvaluator.evaluateExpression(
(ScriptingExpressionType) childExpression.getValue(),
PipelineData.create(object.getValue(), item.getVariables()), context, globalResult));
PipelineData.create(object.getValue(), item.getVariables()), context, globalResult);
if (!BooleanUtils.isFalse(searchExpression.isAggregateOutput())) {
outputData.addAllFrom(expressionResult);
}
globalResult.setSummarizeSuccesses(true);
globalResult.summarize();
} catch (ScriptExecutionException e) {
Expand Down

0 comments on commit 72f79ea

Please sign in to comment.