Skip to content

Commit d11e66a

Browse files
author
Tamer Eldeeb
authored
Do not hold lock on execution when creating task in matching engine (#188)
This could cause a dead lock if synchronous matching tries to update the workflow history
1 parent 5ddccf4 commit d11e66a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

service/history/transferQueueProcessor.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,27 @@ ProcessRetryLoop:
264264
context, release, _ := t.cache.getOrCreateWorkflowExecution(domainID, execution)
265265
var mb *mutableStateBuilder
266266
mb, err = context.loadWorkflowExecution()
267+
timeout := int32(0)
267268
if err == nil {
268269
if ai, found := mb.GetActivityInfo(task.ScheduleID); found {
269-
err = t.matchingClient.AddActivityTask(nil, &m.AddActivityTaskRequest{
270-
DomainUUID: common.StringPtr(targetDomainID),
271-
SourceDomainUUID: common.StringPtr(domainID),
272-
Execution: &execution,
273-
TaskList: taskList,
274-
ScheduleId: &task.ScheduleID,
275-
ScheduleToStartTimeoutSeconds: common.Int32Ptr(ai.ScheduleToStartTimeout),
276-
})
270+
timeout = ai.ScheduleToStartTimeout
277271
} else {
278272
logging.LogDuplicateTransferTaskEvent(t.logger, persistence.TransferTaskTypeActivityTask, task.TaskID, task.ScheduleID)
279273
}
280274
}
281275
release()
276+
277+
if err == nil && timeout != 0 {
278+
err = t.matchingClient.AddActivityTask(nil, &m.AddActivityTaskRequest{
279+
DomainUUID: common.StringPtr(targetDomainID),
280+
SourceDomainUUID: common.StringPtr(domainID),
281+
Execution: &execution,
282+
TaskList: taskList,
283+
ScheduleId: &task.ScheduleID,
284+
ScheduleToStartTimeoutSeconds: common.Int32Ptr(timeout),
285+
})
286+
}
287+
282288
}
283289
case persistence.TransferTaskTypeDecisionTask:
284290
{

0 commit comments

Comments
 (0)