# ExecutionManager threading issue?

**URL:** <https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956>\
**Category:** Module Development\
**Created:** [August 16, 2023, 7:39pm UTC](https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956 "2023-08-16T19:39:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brody\_Massecar](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Brody\_Massecar](https://forum.inductiveautomation.com/u/Brody_Massecar)\
**Post date:** [August 16, 2023, 7:39pm UTC](https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956/1 "2023-08-16T19:39:05Z")

</div>

Hello everyone,

My module has several execution scripts that are making a series of REST calls. I have noticed that when some of these REST calls repeatedly fail (return a bad response), it has been overloading the Ignition system resources and sometimes leading to full crashes. I am trying to troubleshoot what may be at the root of this problem. Here is some context:

1. Here is a list of my execution scripts that are using the shared execution engine:  

2. Here is a sample section of code with how I register these scripts:

```auto
public void register() {
		if(parentRecord.getEnabled().equals(true)) {
			log.info("Launching Agent: {}", execId);
			context.getExecutionManager().register(execId, "ClearAllInterlocks", new ClearAllInterlocks(context, record, execId, parentRecord, httpPool), 500);
			context.getExecutionManager().register(execId, "CreateMission", new CreateMission(context, record, execId, parentRecord, httpPool), 500);
		}
	}

```

1. One thing in particular that I have noticed is that there are an increasingly large number of Timed Waiting threads in the system. I cannot determine what processes are creating these threads or what they belong to by using the Ignition Gateway, but I suspect this may be related to the problem. Here is a snapshot of the system performance when experiencing some of these issues:  
 ![2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/2/c2e08bc49513b2d06ed64845d3ad4651d405fea8.jpeg)

My main suspicion at the moment is that the execution scripts are being registered with a Fixed Rate instead of a Fixed Delay. When the REST calls fail, it is causing the execution time to last longer than the rate and causes a large buildup of Timed Waiting threads. I don't have a ton of visibility into how the ExecutionManager or threading works so I was wondering does this theory make any sense? If not, any other ideas? If so, would the correct solution be to switch from

````auto
context.getExecutionManager().register(execId, "ClearAllInterlocks", new ClearAllInterlocks(context, record, execId, parentRecord, httpPool), 500);```

````

to something like

```auto
context.getExecutionManager().scheduleWithFixedDelay(new ClearAllInterlocks(context, record, execId, parentRecord, httpPool), 500, 500, TimeUnit.MILLISECONDS);

```

Thanks in advance for the help!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 16, 2023, 8:03pm UTC](https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956/2 "2023-08-16T20:03:32Z")

</div>

Take a thread dump from Status \> Diagnostics \> Threads. You'll see all the threads there.

ExecutionManagers used a fixed size thread pool. I'm not sure exactly what you're trying to troubleshoot.

---

<div class="post-metadata">

**Author:** ![Brody\_Massecar](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Brody\_Massecar](https://forum.inductiveautomation.com/u/Brody_Massecar)\
**Post date:** [August 16, 2023, 8:33pm UTC](https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956/3 "2023-08-16T20:33:39Z")

</div>

Hi Kevin,

The Timed Waiting threads seem to be piling up and increasing usage of system resources, which has led to the whole Ignition system crashing. I'm trying to troubleshoot why this is happening.

I was wondering if it is because I am registering my execution scripts using a fixed rate instead of fixed delay. My theory was that the threads are piling up due to the execution lasting longer than the rate which would add new Timed Waiting threads, but I'm not sure how these work. I would like to use the functionality of a fixed delay such that the next thread will execute at the delayed time after the first finishes. I can't tell if I'm using a fixed rate or fixed delay as the Javadocs on these methods aren't particularly clear, so I was hoping for some clarity there.

Additionally, I'm not seeing any threads populate in the table, so I'm unable to take a thread dump. I waited for ~15 mins with nothing being added:

 ![3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/c/ac6c69942fb30cb6d942acd2b2cd1d5adf422dd0.jpeg)

Thanks again!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 16, 2023, 8:48pm UTC](https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956/4 "2023-08-16T20:48:31Z")

</div>

Registering tasks with an ExecutionManager should not cause threads to be created or pile up.

You may need to use the `jstack` utility included with the JDK to get the thread dump instead.

---

<div class="post-metadata">

**Author:** ![Brody\_Massecar](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@Brody\_Massecar](https://forum.inductiveautomation.com/u/Brody_Massecar)\
**Post date:** [August 17, 2023, 3:19pm UTC](https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956/5 "2023-08-17T15:19:50Z")

</div>

Hi Kevin,

I will look into jstack. Do you know what may cause a dramatic increase in Timed Waiting threads?

Also, can you help identify the proper methods to use to register with Fixed Delay vs. methods for registering with Fixed Rate? The Javadoc has some confusing language for its descriptions:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/5/85c5efcd8174b76f18c7ada7582261b92705e7f1.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 17, 2023, 3:37pm UTC](https://forum.inductiveautomation.com/t/executionmanager-threading-issue/77956/6 "2023-08-17T15:37:00Z")

</div>

Timed waiting threads are just threads that aren't doing anything. ExecutionManager's have fixed size thread pools, so unless you're creating new managers they aren't the reason your thread count is growing.

`register` uses fixed delay, `registerAtFixedRate` uses fixed rate. These are not likely relevant to whatever you're troubleshooting.
