# Sometime worker is not able to find the running workflow by workflowId

**URL:** <https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717>\
**Category:** Community Support\
**Tags:** general-impl\
**Created:** [May 17, 2022, 9:01am UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717 "2022-05-17T09:01:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ritesh\_swain](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ritesh_swain/32/2065_2.png) [@ritesh\_swain](https://community.temporal.io/u/ritesh_swain)\
**Post date:** [May 17, 2022, 9:01am UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/1 "2022-05-17T09:01:13Z")

</div>

This method is used to find the running workflow by a workflow Id. Worker pods runs in kubernetes cluster. Sometime this function does not return the running workflow by workflowId but most of the time it works.

```auto
  ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest = ListOpenWorkflowExecutionsRequest.newBuilder().setNamespace(this.client.getOptions().getNamespace()).setExecutionFilter(WorkflowExecutionFilter.newBuilder().setWorkflowId(workflowId).build()).build();

            try {
                return this.getWorkflowClient().getWorkflowServiceStubs().blockingStub().listOpenWorkflowExecutions(listOpenWorkflowExecutionsRequest);
            } catch (StatusRuntimeException var5) {
               
            }

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [May 17, 2022, 1:34pm UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/2 "2022-05-17T13:34:46Z")

</div>

> Sometime this function does not return the running workflow by workflowId but most of the time it works.

In those cases that it doesn’t, are you getting some errors?  
All visibility “List” apis are eventually consistent, meaning information is “near real time” that could have a delay of 2+ seconds depending on your server load. So it could happen that if you call ListOpenWorkflowExecutions right after an server starts an execution, it would not show in results right away.

---

<div class="post-metadata">

**Author:** ![ritesh\_swain](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ritesh_swain/32/2065_2.png) [@ritesh\_swain](https://community.temporal.io/u/ritesh_swain)\
**Post date:** [May 17, 2022, 2:47pm UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/3 "2022-05-17T14:47:48Z")

</div>

Not getting any error . If we retry sometime it returns the running workflow in 5/10 seconds. Sometime it does not return even after 20 seconds. All the scenarios are tested on a running server. Could the issue due to high query response time from DB when the load is high? We use postgresql.

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [May 17, 2022, 3:01pm UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/4 "2022-05-17T15:01:26Z")

</div>

You can use the server “task\_latency\_queue\_bucket” metric to measure visibility task end-to-end latencies, sample query:

`histogram_quantile($percentile, sum(rate(task_latency_queue_bucket{operation=~“VisibilityTask.*“}[1m])) by (operation, le))`

If you have Elasticsearch enabled you can use “visibility\_persistence\_latency\_bucket” metric to track latencies of pushing data to ES:

`sum(rate(visibility_persistence_latency_bucket{visibility_type=“advanced_visibility”}[1m])) by (operation, le))`

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [May 17, 2022, 3:22pm UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/5 "2022-05-17T15:22:06Z")

</div>

You should not rely on the List apis for business decisions because as mentioned it is eventually consistent. You could use apis like DescribeWorkflowExecution or GetWorkflowExecutionHistory which hit your primary db and should not have a latency, but if done on a high scale/rate could impact your server performance.

---

<div class="post-metadata">

**Author:** ![santosh1990](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/santosh1990/32/1772_2.png) [@santosh1990](https://community.temporal.io/u/santosh1990)\
**Post date:** [May 18, 2022, 6:37am UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/6 "2022-05-18T06:37:57Z")

</div>

> [@tihomir](#):
>
> GetWorkflowExecutionHistory

Is there any sample using java SDK for DescribeWorkflowExecution or GetWorkflowExecutionHistory ?

---

<div class="post-metadata">

**Author:** ![santosh1990](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/santosh1990/32/1772_2.png) [@santosh1990](https://community.temporal.io/u/santosh1990)\
**Post date:** [May 18, 2022, 6:43am UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/7 "2022-05-18T06:43:19Z")

</div>

I meant that we need to know how to form the DescribeWorkflowExecutionRequest object before using it in an API call .

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [May 18, 2022, 2:58pm UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/8 "2022-05-18T14:58:42Z")

</div>

@santosh1990

```auto
          DescribeWorkflowExecutionRequest req = DescribeWorkflowExecutionRequest.newBuilder()
                .setExecution(WorkflowExecution.newBuilder()
                        .setWorkflowId("<workflow_id")
                        // optional, if not specified, its either the currently running exec
                        // or the latest completed one
                        .setRunId("<run_id>")
                        .build())
                .setNamespace(client.getOptions().getNamespace())
                .build();

        DescribeWorkflowExecutionResponse res = service.blockingStub().describeWorkflowExecution(req);
        // ...

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [May 18, 2022, 3:00pm UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/9 "2022-05-18T15:00:06Z")

</div>

You can see many of these apis and util methods that might be helpful in our java sdk workshop repo [here](https://github.com/tsurdilo/temporal-java-workshop/blob/main/src/main/java/io/workshop/c1s1/S1WFUtils.java).

---

<div class="post-metadata">

**Author:** ![santosh1990](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/santosh1990/32/1772_2.png) [@santosh1990](https://community.temporal.io/u/santosh1990)\
**Post date:** [May 18, 2022, 3:01pm UTC](https://community.temporal.io/t/sometime-worker-is-not-able-to-find-the-running-workflow-by-workflowid/4717/10 "2022-05-18T15:01:37Z")

</div>

Many thanks
