We are facing an inconsistency in workflow execution status between Temporal Web UI and our application.
Our primary concern is that when we make a GET request to retrieve the workflow status/result, the API returns Running, even though the workflow details page in Temporal Web UI clearly shows Completed.
How can we resolve this without terminating or restarting the workflow?
I assume your Get api gets result from visibility api, so from visibility db you configure with Temporal. So does the list page in the UI.
The execution details page gets info from primary db you configured with Temporal. This is your source of truth. You can run this too using the DescribeWorkflowExecution api (iirc just client.newUntypedWorkflowStub(workflowId).describe().getStatus())
Whats your server version used and what do you use for visibility persistence store (SQL, ES)?
Since visibility tasks have to be moved to visibility store async after exec completion, its normal to have some latency. If in your case this discrepancy of exec status between vis and primary stores persist, take a look at playbook here and look at server dashboard it uses, the panels to look at on dashboard to detect possibly visibility store issues and how do recover in case you had visibility store failures. Hope helps.
When Temporal Web UI shows one status (e.g., Running or ContinuedAsNew) while the CLI or client SDK reports Completed / Failed, this is almost always a Visibility lag between the Execution persistence store (PostgreSQL/Cassandra) and the Visibility store (Elasticsearch or OpenSearch).
Temporal Server updates the shard/execution database immediately in real time, but sends updates to the Visibility store asynchronously via the History host. If the Visibility consumer is experiencing queue backlog or Elasticsearch bulk indexing latency:
Verify the true authoritative state directly via CLI:
temporal workflow show --workflow-id <your-wf-id> --run-id <your-run-id>
The temporal workflow show command queries the execution shard directly, bypassing the Visibility index.
Check Visibility Queue Lag:
Look at the server metric visibility_persistence_execution_time and visibility_errors. If Visibility queue lag is high, workflows will show stale statuses in the Web UI search list until the indexer catches up.
@will1 Will check this but this is only happening for one of my workflow execution, for other this is not the case so this is not the case of visibility queue lag IMO.