-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
13256: Invalidate process cache on deployment rejection r=korthout a=korthout ## Description <!-- Please explain the changes you made here. --> This resolves a critical bug where process instances can be created for processes from rejected deployments. This could lead to unrecoverable partitions. The problem was that a cache is build up for each of the processes during the processing of the `Deployment:CREATE` command, but this cache was not invalidated when that command is rejected. This solution only provides a quick fix by completely clearing the cache, which comes at some performance loss when deployments are rejected. In a future iteration, we'll need to investigate other solutions for the long term. We should also remove the cache entirely from any operations in the immutable ProcessState. ## Related issues <!-- Which issues are closed by this PR or are related --> closes #13254 13275: [Backport stable/8.2] Prevent StackOverFlowError during termination of children r=remcowesterhoud a=backport-action # Description Backport of #13258 to `stable/8.2`. relates to #8955 Co-authored-by: Nico Korthout <[email protected]> Co-authored-by: Nico Korthout <[email protected]> Co-authored-by: Remco Westerhoud <[email protected]>
- Loading branch information
Showing
10 changed files
with
191 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...java/io/camunda/zeebe/engine/processing/processinstance/CancelProcessInstanceBanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.engine.processing.processinstance; | ||
|
||
import io.camunda.zeebe.engine.util.EngineRule; | ||
import io.camunda.zeebe.model.bpmn.Bpmn; | ||
import io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent; | ||
import io.camunda.zeebe.protocol.record.value.BpmnElementType; | ||
import io.camunda.zeebe.test.util.Strings; | ||
import io.camunda.zeebe.test.util.record.RecordingExporter; | ||
import io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestWatcher; | ||
|
||
public final class CancelProcessInstanceBanTest { | ||
|
||
@ClassRule public static final EngineRule ENGINE = EngineRule.singlePartition(); | ||
@Rule public final TestWatcher recordingExporterTestWatcher = new RecordingExporterTestWatcher(); | ||
|
||
@Test // Regression of https://github.com/camunda/zeebe/issues/8955 | ||
public void shouldBanInstanceWhenTerminatingInstanceWithALotOfNestedChildInstances() { | ||
// given | ||
final var amountOfNestedChildInstances = 1000; | ||
final var processId = Strings.newRandomValidBpmnId(); | ||
ENGINE | ||
.deployment() | ||
.withXmlResource( | ||
Bpmn.createExecutableProcess(processId) | ||
.startEvent() | ||
.exclusiveGateway() | ||
.defaultFlow() | ||
.userTask() | ||
.endEvent() | ||
.moveToLastGateway() | ||
.conditionExpression("count < " + amountOfNestedChildInstances) | ||
.intermediateThrowEvent("preventStraightThroughLoop") | ||
.callActivity( | ||
"callActivity", | ||
c -> c.zeebeProcessId(processId).zeebeInputExpression("count + 1", "count")) | ||
.endEvent() | ||
.done()) | ||
.deploy(); | ||
|
||
final long processInstanceKey = | ||
ENGINE.processInstance().ofBpmnProcessId(processId).withVariable("count", 0).create(); | ||
|
||
RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED) | ||
.withElementType(BpmnElementType.USER_TASK) | ||
.getFirst(); | ||
|
||
// when | ||
final var errorRecordValue = | ||
ENGINE.processInstance().withInstanceKey(processInstanceKey).cancelWithError(); | ||
|
||
// then | ||
Assertions.assertThat(errorRecordValue.getValue().getStacktrace()) | ||
.contains("ChildTerminationStackOverflowException"); | ||
Assertions.assertThat(errorRecordValue.getValue().getExceptionMessage()) | ||
.contains( | ||
"Process instance", | ||
""" | ||
has too many nested child instances and could not be terminated. The deepest nested \ | ||
child instance has been banned as a result."""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test-util/src/main/java/io/camunda/zeebe/test/util/record/ErrorRecordStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.test.util.record; | ||
|
||
import io.camunda.zeebe.protocol.record.Record; | ||
import io.camunda.zeebe.protocol.record.value.ErrorRecordValue; | ||
import java.util.stream.Stream; | ||
|
||
public class ErrorRecordStream extends ExporterRecordStream<ErrorRecordValue, ErrorRecordStream> { | ||
|
||
public ErrorRecordStream(final Stream<Record<ErrorRecordValue>> wrappedStream) { | ||
super(wrappedStream); | ||
} | ||
|
||
@Override | ||
protected ErrorRecordStream supply(final Stream<Record<ErrorRecordValue>> wrappedStream) { | ||
return new ErrorRecordStream(wrappedStream); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters