Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE during process instance modification #10606

Closed
lenaschoenburg opened this issue Oct 5, 2022 · 2 comments · Fixed by #10996
Closed

NPE during process instance modification #10606

lenaschoenburg opened this issue Oct 5, 2022 · 2 comments · Fixed by #10996
Assignees
Labels
kind/bug Categorizes an issue or PR as a bug version:8.1.5 Marks an issue as being completely or in parts released in 8.1.5 version:8.2.0-alpha2 Marks an issue as being completely or in parts released in 8.2.0-alpha2 version:8.2.0 Marks an issue as being completely or in parts released in 8.2.0

Comments

@lenaschoenburg
Copy link
Member

lenaschoenburg commented Oct 5, 2022

Describe the bug

Expected to process record 'TypedRecordImpl{metadata=RecordMetadata{recordType=COMMAND, intentValue=255, intent=MODIFY, requestStreamId=1, requestId=37707, protocolVersion=3, valueType=PROCESS_INSTANCE_MODIFICATION, rejectionType=NULL_VAL, rejectionReason=, brokerVersion=8.1.0}, value={"processInstanceKey":2251799813688377,"terminateInstructions":[{"elementInstanceKey":2251799813688383}],"activateInstructions":[{"elementId":"end","ancestorScopeKey":-1,"variableInstructions":[]}]}}' without errors, but exception occurred with message 'Cannot invoke "io.camunda.zeebe.engine.state.instance.ElementInstance.getKey()" because "elementInstance" is null'.

To Reproduce

Unclear, data (ie. models) is not accessible anymore.

Expected behavior

No NPE, if this is expected then we should throw a meaningful exception.

Log/Stacktrace

Full Stacktrace

 java.lang.NullPointerException: Cannot invoke "io.camunda.zeebe.engine.state.instance.ElementInstance.getKey()" because "elementInstance" is null
	at io.camunda.zeebe.engine.processing.processinstance.ProcessInstanceModificationProcessor.terminateElement(ProcessInstanceModificationProcessor.java:535) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.engine.processing.processinstance.ProcessInstanceModificationProcessor.terminateElement(ProcessInstanceModificationProcessor.java:558) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.engine.processing.processinstance.ProcessInstanceModificationProcessor.lambda$processRecord$3(ProcessInstanceModificationProcessor.java:203) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at java.lang.Iterable.forEach(Unknown Source) ~[?:?]
	at io.camunda.zeebe.engine.processing.processinstance.ProcessInstanceModificationProcessor.processRecord(ProcessInstanceModificationProcessor.java:197) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.engine.Engine.process(Engine.java:127) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.streamprocessor.ProcessingStateMachine.lambda$processCommand$3(ProcessingStateMachine.java:261) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.db.impl.rocksdb.transaction.ZeebeTransaction.run(ZeebeTransaction.java:84) ~[zeebe-db-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.streamprocessor.ProcessingStateMachine.processCommand(ProcessingStateMachine.java:257) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.streamprocessor.ProcessingStateMachine.tryToReadNextRecord(ProcessingStateMachine.java:206) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.streamprocessor.ProcessingStateMachine.readNextRecord(ProcessingStateMachine.java:182) ~[zeebe-workflow-engine-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.scheduler.ActorJob.invoke(ActorJob.java:92) ~[zeebe-scheduler-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.scheduler.ActorJob.execute(ActorJob.java:45) ~[zeebe-scheduler-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.scheduler.ActorTask.execute(ActorTask.java:119) ~[zeebe-scheduler-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.scheduler.ActorThread.executeCurrentTask(ActorThread.java:106) ~[zeebe-scheduler-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.scheduler.ActorThread.doWork(ActorThread.java:87) ~[zeebe-scheduler-8.1.0-rc2.jar:8.1.0-rc2]
	at io.camunda.zeebe.scheduler.ActorThread.run(ActorThread.java:198) ~[zeebe-scheduler-8.1.0-rc2.jar:8.1.0-rc2] 

Error group: https://console.cloud.google.com/errors/detail/CNSa-5ifjeT1Og?project=camunda-cloud-240911

Environment:

  • Zeebe Version: 8.1.0-rc2
@lenaschoenburg lenaschoenburg added the kind/bug Categorizes an issue or PR as a bug label Oct 5, 2022
@remcowesterhoud
Copy link
Contributor

This bug has occurred in he medic process now. In my case is was caused by a Call Activity which had an incident whilst mapping the outputs. I've written a test to reproduce it.

  @Test
  public void verifyCallActivityWithIncidentCanBeModified() {
    final var child = Bpmn.createExecutableProcess("child").startEvent().endEvent().done();
    final var parent =
        Bpmn.createExecutableProcess("parent")
            .startEvent()
            .callActivity("callActivity", c -> c.zeebeProcessId("child"))
            .zeebeOutputExpression("x", "y")
            .manualTask("task")
            .endEvent()
            .done();

    ENGINE.deployment().withXmlResource(child).withXmlResource(parent).deploy();

    final var processInstanceKey = ENGINE.processInstance().ofBpmnProcessId("parent").create();

    final var callActivityElement =
        RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED)
            .withProcessInstanceKey(processInstanceKey)
            .withElementId("callActivity")
            .withElementType(BpmnElementType.CALL_ACTIVITY)
            .getFirst();

    Assertions.assertThat(
            RecordingExporter.incidentRecords(IncidentIntent.CREATED)
                .withProcessInstanceKey(processInstanceKey)
                .getFirst())
        .extracting(r -> r.getValue().getElementId())
        .isEqualTo("callActivity");

    ENGINE
        .processInstance()
        .withInstanceKey(processInstanceKey)
        .modification()
        .activateElement("task")
        .terminateElement(callActivityElement.getKey())
        .modify();

    verifyThatRootElementIsActivated(processInstanceKey, "task", BpmnElementType.MANUAL_TASK);
    verifyThatProcessInstanceIsCompleted(processInstanceKey);
  }

I feel like this could be a common scenario in which modification is used and we should aim to fix this in the next patch release. WDYT @saig0?

@remcowesterhoud remcowesterhoud self-assigned this Nov 15, 2022
@remcowesterhoud
Copy link
Contributor

As it's as small fix I'll go ahead and do it.

zeebe-bors-camunda bot added a commit that referenced this issue Nov 22, 2022
11068: [Backport stable/8.1] Prevent NPE when terminating call activity r=remcowesterhoud a=backport-action

# Description
Backport of #10996 to `stable/8.1`.

relates to #10606

Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
@remcowesterhoud remcowesterhoud added version:8.2.0-alpha2 Marks an issue as being completely or in parts released in 8.2.0-alpha2 version:8.1.5 Marks an issue as being completely or in parts released in 8.1.5 labels Dec 6, 2022
@npepinpe npepinpe added the version:8.2.0 Marks an issue as being completely or in parts released in 8.2.0 label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes an issue or PR as a bug version:8.1.5 Marks an issue as being completely or in parts released in 8.1.5 version:8.2.0-alpha2 Marks an issue as being completely or in parts released in 8.2.0-alpha2 version:8.2.0 Marks an issue as being completely or in parts released in 8.2.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants