uber-common / cadence-samples

Other
191 stars 92 forks source link

A wrong way of using Selector which cause unhandled signals #48

Closed longquanzheng closed 3 years ago

longquanzheng commented 3 years ago

You can repro the unhandled signal by these steps:

  1. Start the workflow ./bin/signalcounter , get the WorkflowID from the log
  2. Run the command 11 times to send 11 signals: ./bin/signalcounter -m signal -w <WorkflowID>
  3. Start the worker ./bin/signalcounter -m worker and you will see the log like this:
    (qlong-selector-signal-counter-wrong)$./bin/signalcounter -m worker
    2021-07-14T08:53:26.595-0700    INFO    common/sample_helper.go:109 Logger created.
    2021-07-14T08:53:26.595-0700    DEBUG   common/factory.go:151   Creating RPC dispatcher outbound{"ServiceName": "cadence-frontend", "HostPort": "127.0.0.1:7933"}
    2021-07-14T08:53:26.599-0700    INFO    common/sample_helper.go:161 Domain successfully registered. {"Domain": "samples-domain"}
    2021-07-14T08:53:26.639-0700    INFO    internal/internal_worker.go:833 Started Workflow Worker{"Domain": "samples-domain", "TaskList": "signal_counter", "WorkerID": "96232@IT-USA-25920@signal_counter"}
    2021-07-14T08:53:26.639-0700    INFO    internal/internal_worker.go:837 Worker has no activities registered, so activity worker will not be started.    {"Domain": "samples-domain", "TaskList": "signal_counter", "WorkerID": "96232@IT-USA-25920@signal_counter"}
    2021-07-14T08:53:26.646-0700    INFO    internal/internal_workflow.go:553   Workflow has unhandled signals  {"Domain": "samples-domain", "TaskList": "signal_counter", "WorkerID": "96232@IT-USA-25920@signal_counter", "WorkflowType": "main.sampleSignalCounterWorkflow", "WorkflowID": "signal_counter_1e89daff-5630-4106-b27d-0b86ee0a3cde", "RunID": "e7ad6861-022f-4595-b9e5-e921c6e6f3de", "SignalNames": ["channelA"]}

Unit test would also fail:

=== RUN   TestUnitTestSuite/Test_SampleSignalCounterWorkflow
2021-07-14T08:51:59.334-0700    INFO    internal/internal_workflow.go:553   Workflow has unhandled signals  {"SignalNames": ["channelA"]}
    workflow_test.go:47: 
            Error Trace:    workflow_test.go:47
            Error:          Not equal: 
                            expected: 110
                            actual  : 100
            Test:           TestUnitTestSuite/Test_SampleSignalCounterWorkflow
    --- FAIL: TestUnitTestSuite/Test_SampleSignalCounterWorkflow (0.00s)

Expected :110
Actual   :100