# Consistent 100% CPU use of safeCall-queue thread

**URL:** <https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792>\
**Category:** Runtime\
**Created:** [January 26, 2023, 1:02am UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792 "2023-01-26T01:02:01Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Andrew\_Rowe](https://community.openhab.org/user_avatar/community.openhab.org/andrew_rowe/32/37075_2.png) [@Andrew\_Rowe](https://community.openhab.org/u/Andrew_Rowe)\
**Post date:** [August 7, 2023, 2:43am UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/41 "2023-08-07T02:43:35Z")

</div>

> [@wborn](#):
>
> I asked for a backport to Java 17 in the PR with the fix. 🤞

Wouter… you sir are a flippin’ rockstar!!!

---

<div class="post-metadata">

**Author:** ![splatch](https://community.openhab.org/user_avatar/community.openhab.org/splatch/32/33925_2.png) [@splatch](https://community.openhab.org/u/splatch)\
**Post date:** [August 8, 2023, 10:47am UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/42 "2023-08-08T10:47:08Z")

</div>

Looking at the JVM bug - would it be possible to swap collection implementation to another queue type? This way we do not need to wait for release of JVM.

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 8, 2023, 6:47pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/43 "2023-08-08T18:47:26Z")

</div>

Yes that would be the way to work around it. Maybe replace the buggy Java 17 implementation with the working Java 11 implementation. But it needs to be done everywhere the class is used. That seems to be openhab-core and jupnp for now. But it could also be used in add-ons or their dependencies.

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 9, 2023, 5:19pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/44 "2023-08-09T17:19:56Z")

</div>

I made some bundles with patches to use the Java 11 `LinkedTransferQueue` on Java 17.  
This will only work with OH 4.0.1.  
Maybe someone wants to test it?

You can update the bundles on the Console with these commands:

```auto
bundle:install -s https://github.com/openhab/openhab-base-fixes/releases/download/base-fixes-20230809/base-fixes-1.0.0-SNAPSHOT.jar
bundle:update org.openhab.core https://github.com/wborn/openhab-core/releases/download/base-fixes-20230809/org.openhab.core-4.0.1-SNAPSHOT.jar
bundle:update org.jupnp https://github.com/wborn/jupnp/releases/download/base-fixes-20230809/org.jupnp-2.8.0-SNAPSHOT.jar

```

The org.jupnp update is optional as it may fail if you don’t use any add-on that depends on it.  
After updating the bundles openHAB needs to be restarted for it to work again.

* * *

To revert the changes use these commands:

```auto
bundle:uninstall org.openhab.base-fixes
bundle:update org.openhab.core https://openhab.jfrog.io/artifactory/libs-release/org/openhab/core/bundles/org.openhab.core/4.0.1/org.openhab.core-4.0.1.jar
bundle:update org.jupnp https://repo1.maven.org/maven2/org/jupnp/org.jupnp/2.7.0/org.jupnp-2.7.0.jar

```

Then again restart openHAB.

---

<div class="post-metadata">

**Author:** ![laursen](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@laursen](https://community.openhab.org/u/laursen)\
**Post date:** [August 9, 2023, 8:19pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/45 "2023-08-09T20:19:54Z")

</div>

> [@wborn](#):
>
> You can update the bundles on the Console with these commands:

Good job! For convenience of the willing, perhaps you could also provide the commands for reverting back to the bundled version to be prepared in case of severe issues and/or before upgrading to 4.0.2?

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 9, 2023, 9:04pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/46 "2023-08-09T21:04:42Z")

</div>

> [@laursen](#):
>
> provide the commands for reverting back

They’ve been added to the post now.

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [August 9, 2023, 9:22pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/47 "2023-08-09T21:22:42Z")

</div>

Do I need to Install java11 again?

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 9, 2023, 9:34pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/48 "2023-08-09T21:34:49Z")

</div>

No keep using Java 17, my changes bring some code that did not have these issues from Java 11 to Java 17.

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [August 9, 2023, 9:37pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/49 "2023-08-09T21:37:15Z")

</div>

How do I know if I use an binding which uses jupnp?

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 9, 2023, 9:42pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/50 "2023-08-09T21:42:04Z")

</div>

You can check if the org.jupnp bundle is installed:

```auto
openhab> bundle:list -s | grep org.jupnp
245 │ Active │ 80 │ 2.7.0 │ org.jupnp

```

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [August 9, 2023, 9:47pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/51 "2023-08-09T21:47:15Z")

</div>

One more last question…just for my interest…what is the callsafequeue doing in openhab3 exactly?And what is the issue here? Also it’s fine if you can explain it in simple words.

---

<div class="post-metadata">

**Author:** ![ccutrer](https://community.openhab.org/user_avatar/community.openhab.org/ccutrer/32/73828_2.png) [@ccutrer](https://community.openhab.org/u/ccutrer)\
**Post date:** [August 9, 2023, 9:59pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/52 "2023-08-09T21:59:01Z")

</div>

SafeCaller is a construct in openHAB core that all parts of openHAB can use to wrap something in to prevent it from taking too long (or getting stuck forever). Some more basic examples would be when a rule is executed, when a request is made to an external service, etc. It’s a queue because the main code just adds a task to the queue to run on a different thread, and then when it’s done (successfully or not) the original code can continue.

---

<div class="post-metadata">

**Author:** ![Andrew\_Rowe](https://community.openhab.org/user_avatar/community.openhab.org/andrew_rowe/32/37075_2.png) [@Andrew\_Rowe](https://community.openhab.org/u/Andrew_Rowe)\
**Post date:** [August 9, 2023, 10:33pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/53 "2023-08-09T22:33:53Z")

</div>

Thanks Wouter  
I have installed the patched bundles as per your instructions above after updating to 4.0.1  
My case is one of the most easily reproducible with this issue so it won’t take to long to know if it is working. So far, update went well, everything is running smoothly on 4.0.1 after the update. All Jruby rules re-enabled and fingers crossed

---

<div class="post-metadata">

**Author:** ![jmckenna](https://community.openhab.org/user_avatar/community.openhab.org/jmckenna/32/1202_2.png) [@jmckenna](https://community.openhab.org/u/jmckenna)\
**Post date:** [August 10, 2023, 1:01am UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/54 "2023-08-10T01:01:03Z")

</div>

So far, this is working great for me. I was having issues with items-queue thread.

---

<div class="post-metadata">

**Author:** ![o.s](https://community.openhab.org/letter_avatar_proxy/v4/letter/o/ce7236/32.png) [@o.s](https://community.openhab.org/u/o.s)\
**Post date:** [August 10, 2023, 2:19pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/55 "2023-08-10T14:19:50Z")

</div>

this patch is a huge step wrt performance.  
Now RasPi2 got usabel again for OH4  
Thx!

---

<div class="post-metadata">

**Author:** ![laursen](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@laursen](https://community.openhab.org/u/laursen)\
**Post date:** [August 10, 2023, 3:48pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/56 "2023-08-10T15:48:55Z")

</div>

@wborn - how do you interpret Doug’s latest comment in the PR. “Yes, it’s possible” - or “yes, I’ll do it”? 🙂

In either case, do you know if it will be possible for us to merge the Java 11 version of `LinkedTransferQueue` into our repository without any license problems/conflicts? I’m wondering if we could do this at least in `4.0.x`, as the tests so far looks positive.

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 10, 2023, 4:05pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/57 "2023-08-10T16:05:13Z")

</div>

Meanwhile I had a look at how OpenJDK operates and it looks like other devs typically do the cherry picking of fixes.

If you think openHAB has a formal process, you haven’t seen [theirs](https://wiki.openjdk.org/display/JDKUpdates/JDK+17u) yet.

Fixes first go to [jdk17u-dev](https://github.com/openjdk/jdk17u-dev) and then to the actual update repo [jdk17u](https://github.com/openjdk/jdk17u). So you can monitor the PRs of those repos to see if it gets cherry picked.

OpenJDK uses GPLv2 so that’s why I already put the code for the bundle in a separate [repo](https://github.com/wborn/openhab-base-fixes/).

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 10, 2023, 4:35pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/58 "2023-08-10T16:35:06Z")

</div>

> [@wborn](#):
>
> If you think openHAB has a formal process, you haven’t seen [theirs](https://wiki.openjdk.org/display/JDKUpdates/JDK+17u) yet.

If it were cherry picked and merged today it would still take some time before it gets released:

> - Tuesday, October 17 2023 GA; OpenJDK 17.0.9 released (tag: jdk-17.0.9-ga)

After that it may take more time for Debian/Zulu/Temurin to release builds.

---

<div class="post-metadata">

**Author:** ![laursen](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@laursen](https://community.openhab.org/u/laursen)\
**Post date:** [August 10, 2023, 8:04pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/59 "2023-08-10T20:04:46Z")

</div>

> [@wborn](#):
>
> Fixes first go to [jdk17u-dev](https://github.com/openjdk/jdk17u-dev) and then to the actual update repo [jdk17u](https://github.com/openjdk/jdk17u). So you can monitor the PRs of those repos to see if it gets cherry picked.

It seems nothing more will happen automatically according to the process:

> **[How to contribute or backport a fix - JDK Updates - OpenJDK Wiki](https://wiki.openjdk.org/display/JDKUpdates/How+to+contribute+or+backport+a+fix)**

So I guess Doug was just giving guidance to whoever would pick up the ball and contribute a backport.

From your link there’s also this note in the “Contributing” section:

> Should you not be willing or not be able to drive a fix into JDK 17 updates, you can still suggest changes by dropping a mail to the [jdk-updates-dev mailing list](mailto:jdk-updates-dev@openjdk.java.net). But by only doing that, you are at the grace of the community to pick up your suggestion.

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [August 10, 2023, 8:37pm UTC](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792/60 "2023-08-10T20:37:53Z")

</div>

I would probably opt for the workaround in openHAB so it doesn’t take more than 2 months to get fixed. 🙂

[Previous page](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792.md?page=2)

[Next page](https://community.openhab.org/t/consistent-100-cpu-use-of-safecall-queue-thread/143792.md?page=4)
