# My recursive script and clock drifts

**URL:** <https://forum.inductiveautomation.com/t/my-recursive-script-and-clock-drifts/44137>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [March 5, 2021, 3:19am UTC](https://forum.inductiveautomation.com/t/my-recursive-script-and-clock-drifts/44137 "2021-03-05T03:19:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [March 5, 2021, 3:19am UTC](https://forum.inductiveautomation.com/t/my-recursive-script-and-clock-drifts/44137/1 "2021-03-05T03:19:01Z")

</div>

I made an silly script that looped back into itself, like thoudsands of times over, before I was able to disable it. It was a session property binding that ended up looping back into itself after performing a SQL query. When I opened up the Running Scripts, there was like 4 pages of running scripts, some going on for minutes. As for performance, lots of clock drift, CPU at 90%, memory up the wazoo, you have it.

As for the recursion, no biggie, I mean, it’s happened to me before. Not ideal, but I know what I did. Who hasn’t ever made an infinity loop before? At least I located exactly in the logs when the ‘Flood Limit Tripped’ for the component, but too bad ‘the trip’ didn’t actually stop the loop.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/d/4d3e28833189ab530b8683b68d680a0e5c7f39d3.png)]

So my recursion story leads me to here: after restarting the gateway a couple of times (first red circle is when loop was created, second red circle is when I was able to disable script, third red circle was second gateway restart to try and eliminate clock drift):  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58f0dd5cb524f5fcdc81259b7f035be9c44044bd.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/8/48b7f34fe243c0231e54b696571df3515314569c.png)

So after my second shutdown, now memory is looking good, CPU very happy:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/7/97a5326424e58c53c6bf856c848914b6231eac2f.png)

But I’m seeing a bunch of clock drift errors in my logs, from about 1x every minute to sometimes even faster.

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

The performance of the system is fine. The logs are giving no hints of any problem. The client is running smooth.

It really seems like to me that the problem I created with my recursive loop has somehow made a lasting impact on the system clock monitoring. When I look at the logs, its like night and day different, there were no drifts, then I did my loop, and now there are drifts:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/9/69cbdfd65b876509c7118fe5129e6e2584f39cd3.png)

Any ideas?

---

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [March 5, 2021, 4:32am UTC](https://forum.inductiveautomation.com/t/my-recursive-script-and-clock-drifts/44137/2 "2021-03-05T04:32:16Z")

</div>

Update:  
My clock drifts were fixed once I closed the tab that had the gateway threads on it. Weird that that can cause a clock drift but you don’t see any performance degradation.

Lesson to all - don’t keep the thread diagnostics opened or you will see clock drift errors in the logs.

Even better lesson - don’t create recursive loop in the first place. /solved
