fix(nexus): clear operation callbacks on 'abandon' cancellation. - #2485
Conversation
d8d1427 to
00a803c
Compare
| } | ||
|
|
||
| func (h *commandsHelper) getNexusOperationCommand(seq int64) commandStateMachine { | ||
| return h.getCommand(makeCommandID(commandTypeNexusOperation, strconv.FormatInt(seq, 10))) |
There was a problem hiding this comment.
added a small helper since this manual formatting was repeated in a number of places.
| if !executionFuture.IsReady() { | ||
| executionSettable.Set(nil, ErrCanceled) | ||
| } | ||
| wc.env.AbandonNexusOperation(seq) |
There was a problem hiding this comment.
the fix. clears out the callbacks so we don't try to resolve an already resolved future.
|
We have the same problem for Child Workflows that already does handle this, is there a reason you solved this in a different way then Child Workflows? sdk-go/internal/internal_event_handlers.go Line 1846 in 9a42fac |
2286b50 to
f9333ad
Compare
|
@Quinn-With-Two-Ns I matched the existing nexus pattern of nilling out the callbacks: func (wc *workflowEnvironmentImpl) RequestCancelNexusOperation(seq int64) {
...
data.startedCallback = nil
}The
I actually prefer the idea of having flags/enums for the state here but I feel like that should be it's own PR and would probably need more discussion. I could open another to make that change. |
f9333ad to
6873404
Compare
Was seeing a flakey test (
TestAsyncOperationFromWorkflow_CancellationTypes/Abandon) and traced it back to a bug.What was changed
NexusOperationCancellationTypeAbandonnow correctly clears nexus callbacks.Why?
When you cancel a workflow running a nexus operation with
NexusOperationCancellationTypeAbandon, it operations futures directly but doesn't clear thestartedCallbackorcompletedCallback. Then, when a NexusOperationStarted (or completed) event is received, the stale callbacks fires and attempts to set an already resolved future which panics, which WFT fails.Fixes #2495
Checklist