# PotentialDeadlockException, when does this happen?

**URL:** <https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [April 27, 2021, 2:19pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012 "2021-04-27T14:19:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sherry\_Ummen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/sherry_ummen/32/899_2.png) [@Sherry\_Ummen](https://community.temporal.io/u/Sherry_Ummen)\
**Post date:** [April 27, 2021, 2:19pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/1 "2021-04-27T14:19:45Z")

</div>

Hi,

While experimenting. I get this error

```auto
io.temporal.internal.replay.InternalWorkflowTaskException: Failure handling event 3 of 'EVENT_TYPE_WORKFLOW_TASK_STARTED' type. IsReplaying=false, PreviousStartedEventId=3, workflowTaskStartedEventId=3, Currently Processing StartedEventId=3 
io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:193)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleEvent(ReplayWorkflowRunTaskHandler.java:140)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTaskImpl(ReplayWorkflowRunTaskHandler.java:180)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTask(ReplayWorkflowRunTaskHandler.java:150)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTaskWithEmbeddedQuery(ReplayWorkflowTaskHandler.java:201)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:114)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:319)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:279)
io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:834)

Caused By: java.lang.RuntimeException: WorkflowTask: failure executing SCHEDULED->WORKFLOW_TASK_STARTED, transition history is [CREATED->WORKFLOW_TASK_SCHEDULED] 
io.temporal.internal.statemachines.StateMachine.executeTransition(StateMachine.java:140)
io.temporal.internal.statemachines.StateMachine.handleHistoryEvent(StateMachine.java:91)
io.temporal.internal.statemachines.EntityStateMachineBase.handleEvent(EntityStateMachineBase.java:63)
io.temporal.internal.statemachines.WorkflowStateMachines.handleEventImpl(WorkflowStateMachines.java:210)
io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:178)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleEvent(ReplayWorkflowRunTaskHandler.java:140)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTaskImpl(ReplayWorkflowRunTaskHandler.java:180)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTask(ReplayWorkflowRunTaskHandler.java:150)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTaskWithEmbeddedQuery(ReplayWorkflowTaskHandler.java:201)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:114)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:319)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:279)
io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:834)

Caused By: io.temporal.internal.sync.PotentialDeadlockException: Potential deadlock detected: workflow thread "workflow-method" didn't yield control for over a second. Other workflow 

```

The flow goes so

Kafkaevent stream → calls a funcion → calls a workflow → calls an activity

I am a bit lost on debugging this. any help

---

<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:** [April 27, 2021, 2:32pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/2 "2021-04-27T14:32:38Z")

</div>

Are you getting this error during debugging?

For debugging please set the TEMPORAL\_DEBUG env variable to true – [https://docs.temporal.io/docs/java/testing-and-debugging](https://docs.temporal.io/docs/java/testing-and-debugging)

If not, could you share your workflow code (or parts of it?). Could be that you are not using the dedicated workflow sleep methods (Workflow.sleep) or have some other type of non-deterministic problems.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Sherry\_Ummen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/sherry_ummen/32/899_2.png) [@Sherry\_Ummen](https://community.temporal.io/u/Sherry_Ummen)\
**Post date:** [April 27, 2021, 6:16pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/3 "2021-04-27T18:16:21Z")

</div>

thank you. that was it. I just had to set TEMPORAL\_DEBUG 🙂

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [April 27, 2021, 7:10pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/4 "2021-04-27T19:10:51Z")

</div>

Make sure to set it **only** when you plan to put breakpoints into the workflow code. Any other use might obscure real serious problems with the workflow code.

---

<div class="post-metadata">

**Author:** ![Tejas\_Surve](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tejas_surve/32/5899_2.png) [@Tejas\_Surve](https://community.temporal.io/u/Tejas_Surve)\
**Post date:** [September 25, 2024, 1:01pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/5 "2024-09-25T13:01:14Z")

</div>

I am running 100k workflows on temporal, in workflow i have multiple activities but next activity depends on previous activity result , some of activity have external api calls, workflow.sleep,

getting issue potential deadlock [TMPRL1101] Potential deadlock detected: workflow goroutine “2” didn’t yield for over a second StackTrace coroutine 2 [running]:

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 25, 2024, 9:08pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/6 "2024-09-25T21:08:55Z")

</div>

This can happen if the worker’s process is CPU starved/throttled.

---

<div class="post-metadata">

**Author:** ![Tejas\_Surve](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tejas_surve/32/5899_2.png) [@Tejas\_Surve](https://community.temporal.io/u/Tejas_Surve)\
**Post date:** [September 28, 2024, 10:08am UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/7 "2024-09-28T10:08:51Z")

</div>

I have 8GB RAM AND 250 harddisk mac laptop, running 10k workflows, its causing worker’s process is CPU starved/throttled.? what should worker config for runnning 100k workflows

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 28, 2024, 5:42pm UTC](https://community.temporal.io/t/potentialdeadlockexception-when-does-this-happen/2012/8 "2024-09-28T17:42:34Z")

</div>

Are you using a single binary version of the service? It is not intended for any performance tests.
