openhab-core icon indicating copy to clipboard operation
openhab-core copied to clipboard

Thing manager logic causes things to stuck in NOT_YET_READY

Open splatch opened this issue 2 years ago • 3 comments

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

splatch avatar Oct 03 '23 09:10 splatch

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/creating-a-new-thing-in-own-developed-binding-works-but-after-restart-of-demo-app-the-thing-is-missing-the-thinghandler/159325/8

openhab-bot avatar Oct 04 '24 13:10 openhab-bot

@J-N-K : maybe it "talks" to you?

lolodomo avatar Oct 06 '24 07:10 lolodomo

I wonder why addThingHandlerFactory does not properly remove the missing thingType from the ThingPrerequisites. Can you enable debug logging for the ThingManagerImpl and see in which order the things and the thing handler factory get added?

J-N-K avatar Oct 06 '24 07:10 J-N-K