Concurrent Completion of Multi-Instance User Task Not Throwing Expected Exception

Hi there! :waving_hand:

Thank you for reporting this issue. Based on your description, this appears to be unexpected behavior that contradicts the documented functionality of multi-instance user tasks in Camunda 8.

Expected Behavior

According to the Camunda 8 documentation, when you have a multi-instance user task with a completion condition like numberOfCompletedInstances = 1, the following should happen during concurrent completion attempts:

  1. First user completes their task → Task marked as COMPLETED
  2. Completion condition is met → Multi-instance body completes
  3. Remaining active instances are automatically CANCELED
  4. Second user attempts completion → Should receive a 404 NOT_FOUND error because their task instance was canceled

Your Observed Behavior vs. Expected

:cross_mark: What you observed:

  • Both users successfully execute newUserTaskCompleteCommand without exceptions
  • User A’s task: COMPLETED
  • User B’s task: CANCELED

:white_check_mark: What should happen:

  • User A successfully completes (task marked as COMPLETED)
  • User B should receive a 404 NOT_FOUND exception when attempting completion
  • User B’s task: CANCELED (but the completion command should fail)

Is This a Known Bug?

Based on my research, this specific behavior where both completion commands succeed without throwing the expected 404 NOT_FOUND error is not documented as expected behavior. This suggests it could be a bug in zeebe-client-java version 8.7.2.

Recommendations

  1. Verify your setup: Double-check that your completion condition is correctly configured as numberOfCompletedInstances = 1

  2. Test with error handling: Add proper exception handling around your newUserTaskCompleteCommand calls to catch and log any exceptions that might be occurring

  3. Report the issue: Since this appears to be a deviation from expected behavior, I recommend filing a bug report at the Camunda GitHub repository with:

    • Your exact process model (BPMN)
    • Complete version information (Camunda 8 version, zeebe-client-java 8.7.2)
    • Steps to reproduce the concurrent completion scenario
    • Expected vs. actual behavior

Workaround

Until this is resolved, you might want to implement application-level checks to handle the race condition gracefully, such as checking the task state before attempting completion or implementing proper error handling for concurrent scenarios.

Would you be able to share your BPMN model and the exact code you’re using for task completion? This would help in providing more specific guidance and potentially reproducing the issue.

References: