openhab-core: Thing manager logic causes things to stuck in NOT_YET_READY

I’m in process of updating bindings to OH 4 and spotted a bug, which I believe is related to new logic which improves reliability and predictability of thing startup process.

Bindings I have are rather basic in their form, one which I test with use no dynamic (generated) channels or thing types. Its entirely provided through XML descriptors. However, OH 4.0 makes it stuck in “NOT_YET_READY” state, despite of all descriptors being available and valid.

Expected Behavior

Valid thing types should cause handlers to be initialized.

Current Behavior

Despite of thing descriptors being properly parsed and available thing is marked as not ready, because its handler is refused. I’ve traced it to a logic which populated “missing prerequisites”. It turns that this collection is being feed in few places, but released only in one. This means that depending on startup order (and performance of machine), some handlers may never be used, because thing manager will miss opportunity to remove missing prerequisites, even if these conditions are met. Please see below screenshot where missing prerequisites contains co7io-amsads:network, but thing thing type is already registered in appropriate registry:

image

Steps to Reproduce (for Bugs)

So far I was not able to get a reproducer, as it is strictly speaking, dependent to startup order. If thing is added before thing descriptor is parsed - there is high probability that ThingManager will never update solved prerequisites.

Your Environment

  • openHAB 4.0.3
  • JVM Temurin 17
  • Linux 6.5

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 47 (35 by maintainers)

Commits related to this issue

Most upvoted comments

I just see that in openhab-distro there is a comment on the line ! I give it a try to see if it comes from there !

Start level definition

startlevel:20=dsl:items,managed:item,dsl:things,managed:thing,managed:itemchannellink,dsl:persist #startlevel:30=persistence:restore // do not rely on the presence of a persistence service in the IDE startlevel:40=dsl:rules,managed:rule,rules:refresh,rules:dslprovider startlevel:50=ruleengine:start startlevel:70=dsl:sitemap startlevel:80=things:handler

org.jupnp:autoEnable=false org.jupnp:threadPoolSize=20 org.ops4j.pax.logging:org.ops4j.pax.logging.log4j2.config.file=…/…/…/…/runtime/log4j2.xml

Hello all,

Thanks for your very good analyze @pashalaev. I rework this on my development setup this morning, trying to trace / understand what’s happening.

@J-N-K : I also find that you have made a modification on ThingManagerImpl.java for adding PersistenceService Bundle tracker. In this modification 53889cdcdbf04318d6980a9b8c956f3992bd8337 / September 9), you change the startLevel of the ReadyMarker of ThingManagerImpl.java from 20 to 30 (STARTLEVEL_STATES instead of STARTLEVEL_MODEL).

I’m not fully analyzed what happens so far, but what I can see:

  • When i switch back to STARTLEVEL_MODEL, everything initialized correctly, the onReadyMarkerAdded of ThingManagerImpl is called, things is correctly initialized, and I reach level 100 correctly.

  • When I set the marker to STARTLEVEL_STATES, for some reason, we never hit start level 30. Openhab seems to jump directly from startLevel 20 to startLevel 40. So onReadyMarkerAdded is not called, and things is not correctly initialized.

I will tell you if I find more on this.

Laurent.

Hi! I couldn’t write earlier, but maybe my research will help in some way. On my system, during system startup, the order of calling functions is as follows:

ItemRuntimeActivator.activate() FolderObserver.addModelParser(ModelParser modelParser) FolderObserver.activate()

As I believe, because of this sequence, the correct installation of ReadyMarker dsl:items does not occur and the creation of the openhab/conf/items folder is just a trick that allows the program to continue launching.

From the logic of the program, it becomes clear that the first thing to do is launch the FolderObserver.activate() function, but I’m not such an expert in OSGi that I can say why on my system the sequence of calls is exactly this.

Perhaps this depends on the performance of my system and then it is worth putting the Language Server bundle with ID 201 before the bundle with ID 198 Model Items to give OSGi more time to call FolderObserver.activate()

My openhab/conf folder is empty before opening openhab for the first time. Then the ./ssh and /automation folders created by openhab appear in it and then I create the /items folder manually

My system is esxi 6.5. Xeon E3-1260L 16Gb. For a virtual machine on debian12 with docker, 3 CPUs and 6GB RAM are allocated

Hum, strange. I was not able to reproduce it on clean last snapshot. Definitively need to do some more test to understand what’s wrong in my case. I will give you more information if I find the difference between my setup that was on a snapshot from a few days back, and the clean install i’ve made this morning.

Laurent