Skip to content

Conversation

@mherwege
Copy link
Contributor

Depends on: openhab/openhab-core#4682

This PR removes the default strategy from the persistence configuration and implements a health check on the persistence configuration.

@relativeci
Copy link

relativeci bot commented Mar 31, 2025

#4018 Bundle Size — 12.54MiB (+0.05%).

38f1afd(current) vs 9ae1ca5 main#4017(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 5 changes Regression 1 regression
                 Current
#4018
     Baseline
#4017
Regression  Initial JS 1.52MiB(+0.01%) 1.52MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 7.07% 7.05%
Change  Chunks 620(+0.16%) 619
Change  Assets 702(+0.14%) 701
Change  Modules 2437(+0.04%) 2436
No change  Duplicate Modules 0 0
No change  Duplicate Code 0% 0%
No change  Packages 130 130
No change  Duplicate Packages 1 1
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#4018
     Baseline
#4017
Regression  JS 10.87MiB (+0.05%) 10.86MiB
No change  CSS 846.15KiB 846.15KiB
No change  Fonts 526.1KiB 526.1KiB
No change  Media 295.6KiB 295.6KiB
No change  IMG 45.73KiB 45.73KiB
No change  Other 847B 847B

Bundle analysis reportBranch mherwege:persistence_no_defaultProject dashboard


Generated by RelativeCIDocumentationReport issue

@mherwege mherwege changed the title Persistence no default Persistence strategies not automatically applied Apr 1, 2025
@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI awaiting other PR Depends on another PR labels Apr 5, 2025
@mherwege mherwege force-pushed the persistence_no_default branch from 0f2616c to 3840cbd Compare April 16, 2025 06:28
@florian-h05 florian-h05 marked this pull request as draft April 16, 2025 08:25
@mherwege mherwege force-pushed the persistence_no_default branch from 3840cbd to 054ff5c Compare June 19, 2025 06:36
@mherwege mherwege force-pushed the persistence_no_default branch from 054ff5c to e2c97ef Compare June 30, 2025 06:45
@mherwege mherwege force-pushed the persistence_no_default branch from e2c97ef to fb21f97 Compare July 29, 2025 15:08
@mherwege mherwege force-pushed the persistence_no_default branch from fb21f97 to 114227b Compare October 28, 2025 22:13
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
@mherwege mherwege force-pushed the persistence_no_default branch from 30ccec6 to 796ebf2 Compare November 3, 2025 20:59
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
@kaikreuzer kaikreuzer removed the awaiting other PR Depends on another PR label Dec 14, 2025
@kaikreuzer kaikreuzer marked this pull request as ready for review December 14, 2025 15:51
@kaikreuzer
Copy link
Member

@florian-h05 Might I ask you for a 10 minute speed review? If there isn't anything that you think is a problem, I would merge it now together with openhab/openhab-core#4682.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@florian-h05 As you seem to be afk right now, allow me to merge - if there's any issue with it, let's fix it in a follow-up PR.

@kaikreuzer kaikreuzer merged commit 9e703f3 into openhab:main Dec 14, 2025
4 checks passed
@kaikreuzer kaikreuzer added this to the 5.1 milestone Dec 14, 2025
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have found a number of issues I think originating from rebasing this PR after the Vue 3 upgrade and a few other issues, I will shortly open a PR to fix all my findings.

Apart from that LGTM and thanks for finally replaing the default persistence strategies with something better!

@mherwege mherwege deleted the persistence_no_default branch December 15, 2025 16:41
@helmar74
Copy link

Could someone hav alook in my comments here:
https://community.openhab.org/t/openhab-5-1-milestone-discussion/166385/217

I think there'S a critical issue with persistence settings in RC1
Looks like filebased configuration is not used anymore

@lolodomo
Copy link
Contributor

Looks like filebased configuration is not used anymore

Mine seems to be still used.

@helmar74
Copy link

Looks like filebased configuration is not used anymore

Mine seems to be still used.

Can you share a screenshot from WebUI Persistence settings?

@kaikreuzer
Copy link
Member

Looks like filebased configuration is not used anymore

From the logs that you provided, it seems that the upgrader now adds a managed configuration despite the fact that you already have a textual configuration in place and during startup it picks the "new" managed config and thus it does not regard your "real" textual one anymore:

2025-12-20 09:51:24.172 [WARN ] [ore.common.registry.AbstractRegistry] - Cannot add "PersistenceServiceConfiguration" with key "rrd4j". It exists already from provider "ManagedPersistenceServiceConfigurationProvider"! Failed to add a second with the same UID from provider "PersistenceModelManager"!

If that's the case, that's indeed a very critical issue!

@helmar74
Copy link

Yes it is. Should I delete the added configuration in WebUI in order to fix?

@kaikreuzer
Copy link
Member

I would guess it will resolve your issue, yes. So sure, please have a try. But we will have to investigate this...

@lolodomo
Copy link
Contributor

lolodomo commented Dec 20, 2025

Yes it is. Should I delete the added configuration in WebUI in order to fix?

Stop OH and then look at in userdata/jsondb a find the json file that contains the persistence configuration. Delete this file and then restart openHAB. Sorry I have not in mind the name of the generated file.

Edit: file is org.openhab.core.persistence.PersistenceServiceConfiguration.json

I have not such file myself.

@kaikreuzer
Copy link
Member

kaikreuzer commented Dec 20, 2025

I can confirm the issue. I have a textual inmemory.persist file. When calling the upgradetool with --force option, it logs:

[main] INFO org.openhab.core.tools.internal.PersistenceUpgrader - inmemory: added strategy configurations for persistence service without configuration

which should not happen.

During startup, I then get the warning:

2025-12-20 11:35:05.263 [WARN ] [ore.common.registry.AbstractRegistry] - Cannot add "PersistenceServiceConfiguration" with key "inmemory". It exists already from provider "PersistenceModelManager"! Failed to add a second with the same UID from provider "ManagedPersistenceServiceConfigurationProvider"!

Looking at the PR that I merged yesterday, it indeed does not respect textual configs:

https://github.com/openhab/openhab-core/pull/5212/changes#diff-8e4cccaa92760e57af3bcc119fd6d1e731b88ba3c76582021d080152789242baR83-R88

@helmar74
Copy link

helmar74 commented Dec 20, 2025

For you information.
I deleted rrd4j and mapdb persistence configuration in WebUI, now filebased configuration is used.
Just as "historical" information:

  1. I updated from 5.0.3 (production) to 5.1.0M4 on monday
  2. Today I updated from 5.1.0M4 to 5.1.0RC1

What I also saw, that the permissions for /var/lib/openhab/jsondb/org.openhab.core.persistence.PersistenceServiceConfiguration.json changed to root:root:

-rw-r--r-- 1 root root 1237 20. Dez 09:05 org.openhab.core.persistence.PersistenceServiceConfiguration.json

Maybe this happend thru update to RC1 and caused the issue?
... running on Raspberry PI with openhabian installation. Updates where done with apt update && apt upgrade

Here's my startup log after deleting persistence settings in WebUI:

2025-12-20 11:42:06.957 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading DSL model 'telegram.things'
2025-12-20 11:42:07.164 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading DSL model 'mapdb.persist'
2025-12-20 11:42:07.268 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading DSL model 'rrd4j.persist'
2025-12-20 11:42:07.499 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading DSL model 'Testrule.rules'```

Just ping me, if I should try something. Would be happy to contribute here

@kaikreuzer
Copy link
Member

Looking at the PR that I merged yesterday, it indeed does not respect textual configs:

https://github.com/openhab/openhab-core/pull/5212/changes#diff-8e4cccaa92760e57af3bcc119fd6d1e731b88ba3c76582021d080152789242baR83-R88

This was not the right reference, but this is the place where the file is created with root user rights; this might need to be fixed as well...

Not sure yet, why unmanaged configs are not correctly identified and managed configs are created. Need to investigate.

@mherwege
Copy link
Contributor Author

The upgrader tool should only add a managed persistence configuration for the specific service if there is no .persist file for the service. If there was a persist file and it still does, there still is a bug in the changes to the upgrade tool done yesterday. The upgrade tool lists the existing .persist files and should not add a managed persistence file for these.

@mherwege
Copy link
Contributor Author

Looking at the PR that I merged yesterday, it indeed does not respect textual configs:
https://github.com/openhab/openhab-core/pull/5212/changes#diff-8e4cccaa92760e57af3bcc119fd6d1e731b88ba3c76582021d080152789242baR83-R88

This was not the right reference, but this is the place where the file is created with root user rights; this might need to be fixed as well...
Not sure yet, why unmanaged configs are not correctly identified and managed configs are created. Need to investigate.

The exclusion of the unmanaged ones should be done on line 70 in that file.

@florian-h05
Copy link
Contributor

I've found the bug and seems I have a fix for it.

@florian-h05
Copy link
Contributor

See openhab/openhab-core#5213.

@kaikreuzer
Copy link
Member

What I also saw, that the permissions for /var/lib/openhab/jsondb/org.openhab.core.persistence.PersistenceServiceConfiguration.json changed to root:root

@helmar74 When you say "changed to root:root", does this mean that this file already existed before? Does it contain any information?

@helmar74
Copy link

As far as I can see, the file wasn't there with version 5.0.3 Prod:
image

it wasn't there with version 5.1.0M4:
image

So I think it was created with Update to 5.1.0 RC

@kaikreuzer
Copy link
Member

So I think it was created with Update to 5.1.0 RC

Ok, that's what I expected. So permissions were not changed, but the newly created file was simply created by the root user.

@helmar74
Copy link

Yes it looks like. Update was done with
sudo apt upgrade
as root right's are required on openhabian based installations for apt upgrade

@kaikreuzer
Copy link
Member

I would imagine that this can be an issue, because the runtime might not have write permission to that file, so doing changed through the Main UI might fail.
I am not aware of any other upgrader that already creates new files and how we could deal with setting correct permissions.
The situation here is hopefully a not so common edge case, so it might not be critical to be fixed in 5.1 today.
But if you have any insights or opinions, @mherwege, @florian-h05, @mstormi or others, please chime in!

@mherwege
Copy link
Contributor Author

It looks like @florian-h05 beat me with a solution on this. The change in distro is probably better as it effectively changes ownership. My solution just changes file permissions.

@florian-h05
Copy link
Contributor

florian-h05 commented Dec 20, 2025

I just wanted to comment that I've created openhab/openhab-distro#1847 but you were faster to comment.
I decided to modify the update script in distro as permissions and ownership are OS-specific and I don't want to mess with that in the Java code. In distro, we already have working scripts for handling ownership, let's modify them instead.

florian-h05 added a commit to florian-h05/openhab-linuxpkg that referenced this pull request Dec 20, 2025
florian-h05 added a commit to florian-h05/openhab-linuxpkg that referenced this pull request Dec 20, 2025
kaikreuzer pushed a commit to openhab/openhab-linuxpkg that referenced this pull request Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request main ui Main UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants