172
}
173
if retError != nil && currentWorkflowTask != nil && currentWorkflowTask.Type == enumsspb.WORKFLOW_TASK_TYPE_SPECULATIVE && ms.IsStickyTaskQueueSet() {
174
>
// If, while completing WFT, error is occurred and returned to the worker then worker will clear its cache.
api.go
175
>
// New WFT will also be created on sticky task queue and sent to worker.
176
>
// Because worker doesn't have a workflow in cache, it needs to replay it from the beginning,
177
>
// but sticky WFT has only partial history. Worker will request full history using GetWorkflowExecutionHistory API.
178
>
// This history doesn't have speculative WFT events. If WFT is speculative,
179
>
// then worker will see inconsistency between history from it and full history, and will fail WFT.
180
>
//
181
>
// To prevent unexpected WFT failure, server clears stickiness for this workflow, next WFT will go to normal task queue,
182
>
// and will have full history attached to it.
183
>
// This is NOT 100% bulletproof solution because this write operation may also fail.
184
>
// TODO: remove this call when GetWorkflowExecutionHistory includes speculative WFT events.
185
>
if clearStickyErr := handler.clearStickyTaskQueue(ctx, workflowLease.GetContext()); clearStickyErr != nil {
186
handler.logger.Error("Failed to clear stickiness after speculative workflow task failed to complete.",
187
tag.NewErrorTag("clear-sticky-error", clearStickyErr),