Hi,
I was wondering is it expected for a exception to be thrown when i try to query a workflow that has been terminated? Shouldn’t the replay still work in terms of getting status.
Here is the grpc exception that is being thrown.
io.grpc.StatusRuntimeException: INVALID_ARGUMENT: io.temporal.internal.replay.InternalWorkflowTaskException: Failure handling event 10 of 'EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED' type. IsReplaying=true, PreviousStartedEventId=8, workflowTaskStartedEventId=0, Currently Processing StartedEventId=8
at io.temporal.internal.statemachines.WorkflowStateMachines.createEventProcessingException(WorkflowStateMachines.java:221)
at io.temporal.internal.statemachines.WorkflowStateMachines.handleEventsBatch(WorkflowStateMachines.java:201)
at io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:175)
at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTaskImpl(ReplayWorkflowRunTaskHandler.java:177)
at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleQueryWorkflowTask(ReplayWorkflowRunTaskHandler.java:251)
at io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleQueryOnlyWorkflowTask(ReplayWorkflowTaskHandler.java:257)
at io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:112)
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:319)
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:279)
at io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: Unexpected event:event_id: 10
event_time {
seconds: 1642567913
nanos: 753142552
}
event_type: EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED
task_id: 95996084
workflow_execution_terminated_event_attributes {
details {
payloads {
metadata {
key: "encoding"
value: "binary/null"
}
}
}
identity: "23763@C02C71F6MD6V@"
}
at io.temporal.internal.statemachines.WorkflowStateMachines.handleNonStatefulEvent(WorkflowStateMachines.java:486)
at io.temporal.internal.statemachines.WorkflowStateMachines.handleSingleEvent(WorkflowStateMachines.java:238)
at io.temporal.internal.statemachines.WorkflowStateMachines.handleEventsBatch(WorkflowStateMachines.java:199)
... 11 more
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.queryWorkflow(WorkflowServiceGrpc.java:2983)
at io.temporal.internal.external.GenericWorkflowClientExternalImpl.lambda$query$5(GenericWorkflowClientExternalImpl.java:216)
at io.temporal.internal.retryer.GrpcSyncRetryer.retry(GrpcSyncRetryer.java:61)
at io.temporal.internal.retryer.GrpcRetryer.retryWithResult(GrpcRetryer.java:51)
at io.temporal.internal.external.GenericWorkflowClientExternalImpl.query(GenericWorkflowClientExternalImpl.java:209)
at io.temporal.internal.client.RootWorkflowClientInvoker.query(RootWorkflowClientInvoker.java:141)
at io.temporal.internal.sync.WorkflowStubImpl.query(WorkflowStubImpl.java:342)
... 83 common frames omitted
Wrapped by: io.temporal.client.WorkflowQueryException: workflowId='6dadae4b-8c48-42f8-8002-e6e8e6583e5b', runId='619db0e4-a526-45c5-83cf-2c39619a3211', workflowType='CoolWorkflow'}
at io.temporal.internal.sync.WorkflowStubImpl.query(WorkflowStubImpl.java:349)
at io.temporal.internal.sync.WorkflowInvocationHandler$SyncWorkflowInvocationHandler.queryWorkflow(WorkflowInvocationHandler.java:309)
at io.temporal.internal.sync.WorkflowInvocationHandler$SyncWorkflowInvocationHandler.invoke(WorkflowInvocationHandler.java:272)
Example of code
final TempWorkflow workflow =
workflowClient.newWorkflowStub(
TempWorkflow.class, workflowId.toString(), Optional.of(runId.toString()));
workflow.getStatus();
In this case, when i trigger the workflow query method getStatus
this will throw the exception. The workflow was terminated. Here is a snapshot of what the history looks like
Thanks,
Derek