cadence-workflow / cadence-java-client

Java framework for Cadence Workflow Service
https://cadenceworkflow.io
Other
146 stars 110 forks source link

Java client silently eat error when input is not serializable #374

Closed lihannan99 closed 2 weeks ago

lihannan99 commented 5 years ago

When call java activity from go workflow and java client got DataConverterException, history only show activity heartbeat timeout instead of activity failed.

stack trace from java client.

16:07:12.058 [Activity Executor taskList="HelloActivity", domain="samples-domain": 2] ERROR c.u.c.internal.worker.PollerOptions - uncaught exception
java.lang.RuntimeException: Failure processing activity task. WorkflowID=helloworld_40b7f6d4-77e7-45b7-b68f-81956bea2b0d, RunID=470f25ce-170a-4693-b1b5-b3903ce96af5, ActivityType=GreetingActivities::composeGreeting, ActivityID=0
        at com.uber.cadence.internal.worker.ActivityWorker$TaskHandlerImpl.wrapFailure(ActivityWorker.java:210)
        at com.uber.cadence.internal.worker.ActivityWorker$TaskHandlerImpl.wrapFailure(ActivityWorker.java:146)
        at com.uber.cadence.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:76)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: com.uber.cadence.converter.DataConverterException: when parsing:""hello"
"cadence"
" into following types: [class java.lang.String, class java.lang.String]
        at com.uber.cadence.converter.JsonDataConverter.fromDataArray(JsonDataConverter.java:158)
        at com.uber.cadence.internal.sync.POJOActivityTaskHandler$POJOActivityImplementation.execute(POJOActivityTaskHandler.java:205)
        at com.uber.cadence.internal.sync.POJOActivityTaskHandler.handle(POJOActivityTaskHandler.java:184)
        at com.uber.cadence.internal.worker.ActivityWorker$TaskHandlerImpl.handle(ActivityWorker.java:175)
        at com.uber.cadence.internal.worker.ActivityWorker$TaskHandlerImpl.handle(ActivityWorker.java:146)
        at com.uber.cadence.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:71)
        ... 3 common frames omitted
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 path $
        at com.google.gson.JsonParser.parse(JsonParser.java:65)
        at com.google.gson.JsonParser.parse(JsonParser.java:45)
        at com.uber.cadence.converter.JsonDataConverter.fromDataArray(JsonDataConverter.java:131)
        ... 8 common frames omitted
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 path $
        at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1568)
        at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1409)
        at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542)
        at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
        at com.google.gson.JsonParser.parse(JsonParser.java:60)
        ... 10 common frames omitted

history

   1  WorkflowExecutionStarted    {WorkflowType:{Name:code.uber.internal/devexp/cadence-samples/cmd/samples/recipes/helloworld.Workflow},
                                  TaskList:{Name:cadence-samples-tasklist}, Input:["Cadence"], ExecutionStartToCloseTimeoutSeconds:60,
                                  TaskStartToCloseTimeoutSeconds:60, ContinuedFailureDetails:[], LastCompletionResult:[],
                                  OriginalExecutionRunId:470f25ce-170a-4693-b1b5-b3903ce96af5, Identity:98733@hanli-C02WM0PAHTDG@,
                                  FirstExecutionRunId:470f25ce-170a-4693-b1b5-b3903ce96af5, Attempt:0, FirstDecisionTaskBackoffSeconds:0}
   2  DecisionTaskScheduled       {TaskList:{Name:cadence-samples-tasklist},
                                  StartToCloseTimeoutSeconds:60, Attempt:0}
   3  DecisionTaskStarted         {ScheduledEventId:2,
                                  Identity:98728@hanli-C02WM0PAHTDG@cadence-samples-tasklist,
                                  RequestId:af0122f8-10e7-4080-9f11-12b126bfc581}
   4  DecisionTaskCompleted       {ExecutionContext:[], ScheduledEventId:2, StartedEventId:3,
                                  Identity:98728@hanli-C02WM0PAHTDG@cadence-samples-tasklist,
                                  BinaryChecksum:d69f1d1762494632fea9a52d10e0fdad}
   5  ActivityTaskScheduled       {ActivityId:0,
                                  ActivityType:{Name:GreetingActivities::composeGreeting},
                                  TaskList:{Name:HelloActivity}, Input:["hello"
                                  "cadence"], ScheduleToCloseTimeoutSeconds:20,
                                  ScheduleToStartTimeoutSeconds:10,
                                  StartToCloseTimeoutSeconds:10,
                                  HeartbeatTimeoutSeconds:5,
                                  DecisionTaskCompletedEventId:4}
   6  ActivityTaskStarted         {ScheduledEventId:5,
                                  Identity:90049@hanli-C02WM0PAHTDG,
                                  RequestId:7d0671e4-c5da-479c-a8d9-ab0691ba6ed7,
                                  Attempt:0}
   7  ActivityTaskTimedOut        {Details:[],
                                  ScheduledEventId:5,
                                  StartedEventId:6,
                                  TimeoutType:HEARTBEAT}
   8  DecisionTaskScheduled       {TaskList:{Name:hanli-C02WM0PAHTDG:11453c82-a679-409b-8e63-1dafd5beb62f},
                                  StartToCloseTimeoutSeconds:60, Attempt:0}
   9  DecisionTaskStarted         {ScheduledEventId:8,
                                  Identity:98728@hanli-C02WM0PAHTDG@cadence-samples-tasklist,
                                  RequestId:c210bcea-60d8-4426-a362-5e5f2f39b507}
  10  DecisionTaskCompleted       {ExecutionContext:[], ScheduledEventId:8, StartedEventId:9,
                                  Identity:98728@hanli-C02WM0PAHTDG@cadence-samples-tasklist,
                                  BinaryChecksum:d69f1d1762494632fea9a52d10e0fdad}
  11  WorkflowExecutionCompleted  {Result:[],
                                  DecisionTaskCompletedEventId:10}

To reproduce, start a java worker (e.g. hello.HelloActivity) start a go worker and go workflow, edit that workflow to call java activity

    e := workflow.ExecuteActivity(ctx, "GreetingActivities::composeGreeting", "hello", "world").Get(ctx, &resp)
mfateev commented 5 years ago

Fix: https://github.com/uber/cadence-java-client/pull/381