Files
Roey BermanandAlex Shtin 57ce55d624 Fix replication issues with nexus operations and cancelation requests (#6457)
Changed the operation cancelation logic to not cancel the operation if
the operation hasn't been started yet.
Before this change canceling an operation would add a
NEXUS_OPERATION_CANCELED event and immediately transition to the
`Canceled` state, which had issues with replication and buffered events.
E.g. the `Started` event would be applied before the `CancelRequested`
event on one cluster and then applied in reverse order when replicating
to another cluster.

Example history batch taken from a test cluster contains these events:

```
EVENT_TYPE_WORKFLOW_TASK_COMPLETED
EVENT_TYPE_NEXUS_OPERATION_CANCEL_REQUESTED
EVENT_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED
EVENT_TYPE_NEXUS_OPERATION_STARTED // <-- this had to be buffered
EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
EVENT_TYPE_WORKFLOW_TASK_STARTED
```

The new code path simply creates the cancelation state machine but
doesn't actually cancel it, instead it lets the task executor attempt to
resolve the machine as canceled.

Eventually we'll want to properly support cancel-before-started. At the
moment, we may end up starting an operation and leave it oblivious of
the cancelation request.

I didn't test the replication issue but the new code path avoids
ordering issues by not transitioning to canceled state.
Added unit tests for the executor changes and modified the state machine
tests.

We should patch 120 and maybe even 119. The latter will be promoted to
OSS 1.25.0 but since we explicitly state that Nexus in 1.25.0 isn't
suited for multi cluster deployments, we could skip this patch.
2024-11-04 17:35:37 -08:00
..