Skip to content
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

Karaf cache not cleaned after upgrade #1696

Open
mstormi opened this issue Nov 14, 2024 · 9 comments
Open

Karaf cache not cleaned after upgrade #1696

mstormi opened this issue Nov 14, 2024 · 9 comments
Labels
bug An unexpected problem or unintended behavior

Comments

@mstormi
Copy link
Contributor

mstormi commented Nov 14, 2024

I noticed on various occasions that openHAB didn't start properly after a package upgrade.

On every of these, I had to manually clean the cache to make it finally start (or to proceed after start, actually - it starts in fact but keeps hanging).

@BClark09 I'd prefer if we sort this out before OH 4.3 release Dec 15.

@mstormi mstormi added the bug An unexpected problem or unintended behavior label Nov 14, 2024
@BClark09
Copy link
Member

BClark09 commented Nov 14, 2024

When you mention Karaf cache, do you mean cache and tmp directories inside ${OPENHAB_USERDIR}? or just the .karaf dir?

If cache and tmp, these are indeed removed in the distro's update scripts without condition. (Note that Linuxpkg does this in a similar way). Have you tried completing an upgrade without openHAB running and then looking to see if the files still exist?

If .karaf, what is stored here? I thought it was just the console history?

@mstormi
Copy link
Contributor Author

mstormi commented Nov 14, 2024 via email

@mike-bike
Copy link

mike-bike commented Nov 14, 2024

Not sure if it helps. I do see sometimes start-up issues (Bindings not all initializing, etc) on the first start after an upgrade. Most of the time I do a stop, clean-cache, restart. However, I was also able to get a clean start after a stop and start without cache clean. Maybe there are sometimes timing issues in the first start after an upgrade. Unfortunately, this seems not to be reproducible.

@andrewfg
Copy link
Contributor

Most of the time I do a stop, clean-cache, restart

Me too. This should be automated!

@BClark09
Copy link
Member

I think we need to understand what the problem is and where it's coming from.

From what I understand, there seems to be a problem on first launch of an upgrade for some people and this issue is resolved by cleaning the cache. That does not mean that the cache isn't cleaned on an upgrade:

ben@smarthome:~ $ sudo systemctl stop openhab
ben@smarthome:~ $ du -sh ${OPENHAB_USERDATA}/*
4.0K    /var/lib/openhab/backups
140M    /var/lib/openhab/cache
292K    /var/lib/openhab/config
304K    /var/lib/openhab/etc
3.7M    /var/lib/openhab/jsondb
81M     /var/lib/openhab/persistence
162M    /var/lib/openhab/piper
8.0K    /var/lib/openhab/secrets
90M     /var/lib/openhab/tmp
4.0K    /var/lib/openhab/zigbee
144K    /var/lib/openhab/zwave
ben@smarthome:~ $ sudo apt install openhab
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be upgraded:
  openhab
1 upgraded, 0 newly installed, 0 to remove and 59 not upgraded.
Need to get 111 MB of archives.

[...]

[openHAB] JSON Database upgrade completed.
[openHAB] openHAB was not running so will not start after upgrade.
[openHAB] Please use the command:
            sudo /bin/systemctl start openhab.service

ben@smarthome:~ $ du -sh ${OPENHAB_USERDATA}/*
4.0K    /var/lib/openhab/backups
288K    /var/lib/openhab/config
304K    /var/lib/openhab/etc
3.7M    /var/lib/openhab/jsondb
81M     /var/lib/openhab/persistence
162M    /var/lib/openhab/piper
8.0K    /var/lib/openhab/secrets
4.0K    /var/lib/openhab/tmp
4.0K    /var/lib/openhab/zigbee
144K    /var/lib/openhab/zwave

You can see from above that the cache and tmp directories have indeed been cleaned during the upgrade process. This will be the same if you're using the distributions update scripts.

@andrewfg
Copy link
Contributor

I suppose that if the cached files are in memory then deleting the disk images does not automatically clear the memory image. Also probably a service restart won't clear the memory images either. I suppose that only a full shutdown and reboot would do that.

@BClark09
Copy link
Member

BClark09 commented Nov 20, 2024

The openHAB service is shutdown during an upgrade (or in the case of the distribution scripts, the update wont run at all until openHAB is stopped), so there should be no instance in memory.

@mstormi
Copy link
Contributor Author

mstormi commented Nov 20, 2024

You can see from above that the cache and tmp directories have indeed been cleaned during the upgrade process. This will be the same if you're using the distributions update scripts.

Did you check if exactly the same will happen when I manually run openhab-cli clean-cache ?

@BClark09
Copy link
Member

BClark09 commented Nov 20, 2024

I only have my real-home system to test with at the moment, so won't manually run the command myself. But as far as I can see there's no functional difference in the commands it uses vs the update scripts:

https://github.com/openhab/openhab-linuxpkg/blob/main/resources/usr/bin/openhab-cli#L99-L101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants