Skip to content

Commit ed50efa

Browse files
Skip domain check for replayDomain for decision checking (#764)
1 parent b763217 commit ed50efa

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

internal/internal_task_handlers.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ func isDecisionMatchEvent(d *s.Decision, e *s.HistoryEvent, strictMode bool) boo
11841184
}
11851185
eventAttributes := e.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes
11861186
decisionAttributes := d.RequestCancelExternalWorkflowExecutionDecisionAttributes
1187-
if eventAttributes.GetDomain() != decisionAttributes.GetDomain() ||
1187+
if checkIfDecisionDomainMatchEventDomain(eventAttributes.GetDomain(), decisionAttributes.GetDomain()) ||
11881188
eventAttributes.WorkflowExecution.GetWorkflowId() != decisionAttributes.GetWorkflowId() {
11891189
return false
11901190
}
@@ -1197,7 +1197,7 @@ func isDecisionMatchEvent(d *s.Decision, e *s.HistoryEvent, strictMode bool) boo
11971197
}
11981198
eventAttributes := e.SignalExternalWorkflowExecutionInitiatedEventAttributes
11991199
decisionAttributes := d.SignalExternalWorkflowExecutionDecisionAttributes
1200-
if eventAttributes.GetDomain() != decisionAttributes.GetDomain() ||
1200+
if checkIfDecisionDomainMatchEventDomain(eventAttributes.GetDomain(), decisionAttributes.GetDomain()) ||
12011201
eventAttributes.GetSignalName() != decisionAttributes.GetSignalName() ||
12021202
eventAttributes.WorkflowExecution.GetWorkflowId() != decisionAttributes.Execution.GetWorkflowId() {
12031203
return false
@@ -1232,7 +1232,7 @@ func isDecisionMatchEvent(d *s.Decision, e *s.HistoryEvent, strictMode bool) boo
12321232
eventAttributes := e.StartChildWorkflowExecutionInitiatedEventAttributes
12331233
decisionAttributes := d.StartChildWorkflowExecutionDecisionAttributes
12341234
if lastPartOfName(eventAttributes.WorkflowType.GetName()) != lastPartOfName(decisionAttributes.WorkflowType.GetName()) ||
1235-
(strictMode && eventAttributes.GetDomain() != decisionAttributes.GetDomain()) ||
1235+
(strictMode && checkIfDecisionDomainMatchEventDomain(eventAttributes.GetDomain(), decisionAttributes.GetDomain())) ||
12361236
(strictMode && eventAttributes.TaskList.GetName() != decisionAttributes.TaskList.GetName()) {
12371237
return false
12381238
}
@@ -1243,6 +1243,13 @@ func isDecisionMatchEvent(d *s.Decision, e *s.HistoryEvent, strictMode bool) boo
12431243
return false
12441244
}
12451245

1246+
func checkIfDecisionDomainMatchEventDomain(eventDomainName, decisionDomainName string) bool {
1247+
if decisionDomainName == "" || IsReplayDomain(decisionDomainName) {
1248+
return true
1249+
}
1250+
return eventDomainName == decisionDomainName
1251+
}
1252+
12461253
func (wth *workflowTaskHandlerImpl) completeWorkflow(
12471254
eventHandler *workflowExecutionEventHandlerImpl,
12481255
task *s.PollForDecisionTaskResponse,

internal/worker.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,15 @@ const (
235235
// Whereas default does *NOT* reply anything back to the server, fail workflow replies back with a request
236236
// to fail the workflow execution.
237237
NonDeterministicWorkflowPolicyFailWorkflow
238+
239+
// we have to put a domainName for replay because startEvent doesn't contain it
240+
ReplayDomainName = "ReplayDomain"
238241
)
239242

243+
func IsReplayDomain(dn string) bool {
244+
return ReplayDomainName == dn
245+
}
246+
240247
// NewWorker creates an instance of worker for managing workflow and activity executions.
241248
// service - thrift connection to the cadence server.
242249
// domain - the name of the cadence domain.
@@ -285,9 +292,7 @@ func ReplayWorkflowHistory(logger *zap.Logger, history *shared.History) error {
285292
controller := gomock.NewController(testReporter)
286293
service := workflowservicetest.NewMockClient(controller)
287294

288-
domain := "ReplayDomain"
289-
290-
return replayWorkflowHistory(logger, service, domain, history)
295+
return replayWorkflowHistory(logger, service, ReplayDomainName, history)
291296
}
292297

293298
// ReplayWorkflowHistoryFromJSONFile executes a single decision task for the given json history file.
@@ -309,9 +314,7 @@ func ReplayWorkflowHistoryFromJSONFile(logger *zap.Logger, jsonfileName string)
309314
controller := gomock.NewController(testReporter)
310315
service := workflowservicetest.NewMockClient(controller)
311316

312-
domain := "ReplayDomain"
313-
314-
return replayWorkflowHistory(logger, service, domain, history)
317+
return replayWorkflowHistory(logger, service, ReplayDomainName, history)
315318
}
316319

317320
func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Interface, domain string, history *shared.History) error {
@@ -358,7 +361,7 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
358361
iterator := &historyIteratorImpl{
359362
nextPageToken: task.NextPageToken,
360363
execution: task.WorkflowExecution,
361-
domain: "ReplayDomain",
364+
domain: ReplayDomainName,
362365
service: service,
363366
metricsScope: metricScope,
364367
maxEventID: task.GetStartedEventId(),

0 commit comments

Comments
 (0)