diff --git a/service/history/workflow/update/update.go b/service/history/workflow/update/update.go index 23a8a82ce94..aafa7cbf60c 100644 --- a/service/history/workflow/update/update.go +++ b/service/history/workflow/update/update.go @@ -34,6 +34,7 @@ import ( protocolpb "go.temporal.io/api/protocol/v1" updatepb "go.temporal.io/api/update/v1" + "go.temporal.io/server/common" "go.temporal.io/server/common/future" "go.temporal.io/server/internal/effect" ) @@ -283,14 +284,17 @@ func (u *Update) onAcceptanceMsg( if err != nil { return err } + u.acceptedEventID = event.EventId u.setState(stateProvisionallyAccepted) eventStore.OnAfterCommit(func(context.Context) { u.request = nil - u.acceptedEventID = event.EventId u.setState(stateAccepted) u.accepted.(*future.FutureImpl[*failurepb.Failure]).Set(nil, nil) }) - eventStore.OnAfterRollback(func(context.Context) { u.setState(stateRequested) }) + eventStore.OnAfterRollback(func(context.Context) { + u.acceptedEventID = common.EmptyEventID + u.setState(stateRequested) + }) return nil } diff --git a/service/history/workflow/update/update_test.go b/service/history/workflow/update/update_test.go index 29acfad98bd..c7118aae153 100644 --- a/service/history/workflow/update/update_test.go +++ b/service/history/workflow/update/update_test.go @@ -575,7 +575,8 @@ func TestAcceptEventIDInCompletedEvent(t *testing.T) { t.Parallel() var ( ctx = context.Background() - store = mockEventStore{Controller: effect.Immediate(ctx)} + effects = effect.Buffer{} + store = mockEventStore{Controller: &effects} updateID = t.Name() + "-update-id" upd = update.New(updateID) req = updatepb.Request{ @@ -611,7 +612,9 @@ func TestAcceptEventIDInCompletedEvent(t *testing.T) { } require.NoError(t, upd.OnMessage(ctx, &req, store)) + effects.Apply(ctx) require.NoError(t, upd.OnMessage(ctx, &acpt, store)) require.NoError(t, upd.OnMessage(ctx, &resp, store)) + effects.Apply(ctx) require.Equal(t, wantAcceptedEventID, gotAcceptedEventID) }