Skip to content

Commit 61c4836

Browse files
Bug fix: workaround cadence client bug of concurrent map writes (#125)
1 parent 1b0762c commit 61c4836

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ cadence adm cl asa --search_attr_key IwfGlobalWorkflowVersion --search_attr_type
7676
cadence adm cl asa --search_attr_key IwfExecutingStateIds --search_attr_type 1
7777
cadence adm cl asa --search_attr_key IwfWorkflowType --search_attr_type 1
7878
```
79+
After registering, it may take [up 60s](https://github.com/uber/cadence/blob/d618e32ac5ea05c411cca08c3e4859e800daa1e0/docker/config_template.yaml#L286) for Cadence to load the new search attributes. If you run the test too early, you may see error:
80+
like `"IwfWorkflowType is not a valid search attribute key"`
7981
4. Go to Cadence http://localhost:8088/domains/default/workflows?range=last-30-days
8082

8183
If you run into any issues with Search Attributes registration, use the below command to check the existing Search attributes:

service/interpreter/workflowImpl.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,16 @@ func InterpreterImpl(ctx UnifiedContext, provider WorkflowProvider, input servic
7979
)
8080
return
8181
}
82-
defer func() {
82+
manualDeferFn := func() {
83+
// using defer will cause https://github.com/uber-go/cadence-client/issues/1198 in Cadence
84+
// so we use manual defer here...
85+
// NOTE: must execute this in every place when return...
86+
// TODO be extremely careful in this piece of code, and remove this hack when the bug is fixed in Cadence client
8387
err := stateExecutingMgr.completeStates(state)
8488
if err != nil {
8589
errToFailWf = err
8690
}
87-
}()
91+
}
8892

8993
stateExeId := stateExeIdMgr.IncAndGetNextExecutionId(state.GetStateId())
9094
decision, err := executeState(ctx, provider, state, execution, stateExeId, persistenceManager, interStateChannel)
@@ -111,6 +115,7 @@ func InterpreterImpl(ctx UnifiedContext, provider WorkflowProvider, input servic
111115
if !shouldClose && decision.HasNextStates() {
112116
currentStates = append(currentStates, decision.GetNextStates()...)
113117
}
118+
manualDeferFn()
114119
})
115120
}
116121

0 commit comments

Comments
 (0)