-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a PersistenceService bundle tracker #4324
Conversation
Signed-off-by: Jan N. Klug <github@klug.nrw>
By ready, does it mean also with user persistence configuration loaded ? |
It probably reduces the problem, because the startup order is more deterministic and the short time where the "wrong" configuration is applied is moved to a point where no item updates are sent. But as long as the "default persistence strategy" is allowed (and there was a lengthy discussion about that here where everybody except myself voted for keeping and even extending them) the issue will not go away. The only way to really solve it would be to remove the default strategies and wait for the selected configuration to be applied - the service can't decide if the default strategy is what is used intentionally or if another configuration is just not yet loaded. |
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
This PR sounds like a good idea. I did get some startup messages on my latest update to 4.2.1 that I don't recall from before. No issues observed after a few seconds. OH in docker on RPI5. Included a few surrounding messages for context in case that helps.
|
Just to mention it, I did only vote for the default strategy because I did not see a good alternative. @J-N-K Please let me know what you think. |
Fully agree, and that is also what I proposed when this was originally discussed. |
I don‘t think necessarily. If there is a config file, everything is fine. If there is no config file and no managed config (which I think core should be able to detect), we can use the recommended config and store it as a new managed config. Do you agree or do I have a misconception? |
I need to think this through a bit more. If you upgrade and there is no file, it can be created automatically as managed configuration. But the user then needs to remove it again and create a file version if he/she prefers that (and wants to change it). I guess we may end up in situations where there is a managed config and a file config at the same time. While I like the idea of automatically creating a managed config, I guess this is an area where we risk having issues with users creating file configs afterwards. The answer is: you shouldn’t, and only one config is allowed, but still. So maybe we should not do it automatically after all and have update instructions stating no default is applied, and it can be created in a file or by saving the proposed config in the UI. |
Maybe true, but I can already see a few users writing on the forum „my persistence stopped working“ because they didn‘t read the release notes/breaking changes section no matter how often we tell them to do … I guess this just happens. And sorry for getting off-topic here … |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Nice RFC of the bundle tracker, and I consider it always a good thing to make startup more determinist.
Just one minor comment from my side.
...es/org.openhab.core/src/main/java/org/openhab/core/service/AbstractServiceBundleTracker.java
Outdated
Show resolved
Hide resolved
For all other configs, the file takes precedence. I would expect this to be the same. If a file exists, it's marked as "read only" so MainUI doesn't allow editing of it and anything that may have been done in MainUI prior gets masked by the file. |
@rkoshak I think that's not something you should place a bet on. There is no precedence in core, the first one wins. Maybe this is textual config on most cases, but it is not guaranteed. In general: there should be no "automatic managed configuration". The "default" could be suggested and be set as managed if accepted, but that should not happen without user interaction. |
It used to be the case that the file always took precidence. Maybe it was never that cut and dry (though we were told that it was at the time) or maybe things are different now. This goes back to OH 2 times so it might have become less determinisitic than it once was. Or maybe we've been lucky becuase loading and parsing files is so much more slow than loading managed configs? |
…e/AbstractServiceBundleTracker.java Co-authored-by: Florian Hotze <florianh_dev@icloud.com> Signed-off-by: J-N-K <github@klug.nrw>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
While working on adding time series support to the Awattar binding I found that - depending on the installation order - things might get initialized before all persistence services are ready. It might happen that this leads to issues with persisting data (because a state or time series is sent before the persistence service is ready).
I propose to add a persistence service bundle tracker (similar to what we have for script engine factories) and prevent early thing initialization. Adding the new
persistence=services
ready marker as a requirement to start level 30 and delaying thing initialization until that level is reached makes sure that persistence services are ready.Increasing the minimum start level for thing initialization also solves another issue reported on the forum: things initialized before scripting add-ons might result in warnings that a script engine factory is missing for the
SCRIPT
transformation used in profiles.There might be a short delay in startup but IMO the benefits outweigh that - and maybe it doesn't influence the total startup time that much because the scripting add-ons and the persistence add-ons are just started earlier than before. They are now using more ressources during early startup but less on later levels.