cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Domain is hardcoded in ReplayWorkflowHistory and ReplayWorkflowHistoryFromJSONFile

Open scott-hornberger opened this issue 7 years ago • 1 comments

Bug:

In internal/worker.go, domain is hardcoded to domain = "ReplayDomain". This causes a false positive for "nondeterministic workflow".

See here:

nondeterministic workflow: history event is SignalExternalWorkflowExecutionInitiated: (EventId:11, Timestamp:1554245511648556500, EventType:SignalExternalWorkflowExecutionInitiated, Version:-24, SignalExternalWorkflowExecutionInitiatedEventAttributes:(DecisionTaskCompletedEventId:10, Domain:coconut-api-dev-domain, WorkflowExecution:(WorkflowId:operation.project.p0.service.coconut-dummy-service, RunId:9ced7ed9-4dda-4877-bb99-bdc4bc13db77), SignalName:service-op-event-channel, Input:[{"Detail":"","SignalID":"b61834ca-5b5d-44f5-96c6-b4ca9bdb1eea"}], Control:[1], ChildWorkflowOnly:false)), replay decision is SignalExternalWorkflowExecution: (DecisionType:SignalExternalWorkflowExecution, SignalExternalWorkflowExecutionDecisionAttributes:(Domain:ReplayDomain, Execution:(WorkflowId:operation.project.p0.service.coconut-dummy-service, RunId:9ced7ed9-4dda-4877-bb99-bdc4bc13db77), SignalName:service-op-event-channel, Input:[{"Detail":"","SignalID":"b61834ca-5b5d-44f5-96c6-b4ca9bdb1eea"}], Control:[1], ChildWorkflowOnly:false))

Main focus of history vs. replay:

... Domain:coconut-api-dev-domain ...
... Domain:ReplayDomain ...

Simple fix The problem is fixed if I update the code base to be:

// worker/worker.go
func ReplayWorkflowHistoryFromJSONFile(logger *zap.Logger, domain string, jsonfileName string) error {
	return internal.ReplayWorkflowHistoryFromJSONFile(logger, domain, jsonfileName)
}
// internal/worker.go
func ReplayWorkflowHistoryFromJSONFile(logger *zap.Logger, domain string, jsonfileName string) error {

	history, err := extractHistoryFromFile(jsonfileName)

	if err != nil {
		return err
	}

	if logger == nil {
		logger = zap.NewNop()
	}

	testReporter := logger.Sugar()
	controller := gomock.NewController(testReporter)
	service := workflowservicetest.NewMockClient(controller)
	if len(domain) == 0 {
		domain = "ReplayDomain"
	}

	return replayWorkflowHistory(logger, service, domain, history)
}

Important side note: This problem also causes a panic.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x181ed7f]

goroutine 45 [running]:
code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal.(*workflowExecutionContextImpl).queueResetStickinessTask(...)
	/Users/scotthornberger/gocode/src/code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal/internal_task_handlers.go:442
code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal.(*workflowExecutionContextImpl).onEviction(0xc0000e3550)
	/Users/scotthornberger/gocode/src/code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal/internal_task_handlers.go:422 +0x1cf
code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal.getWorkflowCache.func1.1(0x1bc8ee0, 0xc0000e3550)
	/Users/scotthornberger/gocode/src/code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal/internal_task_handlers.go:355 +0x3c
created by code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal/common/cache.(*lru).Delete
	/Users/scotthornberger/gocode/src/code.uber.internal/infra/coconut/vendor/go.uber.org/cadence/internal/common/cache/lru.go:139 +0x175

I did not investigate the panic further.

scott-hornberger avatar Apr 03 '19 16:04 scott-hornberger

moved to client side and close this issue

lihannan99 avatar Apr 15 '19 23:04 lihannan99