eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
864 stars 782 forks source link

Configuration reload fails two times before successful reload #3192

Closed itn3rd77 closed 7 years ago

itn3rd77 commented 7 years ago

Hi,

when I edit and save a config file inside the conf folder I see two IOExceptions before the reload is successful.

2017-03-30 13:59:58.673 [ERROR] [.core.internal.folder.FolderObserver] - Error handling update of file '/var/packages/openHAB2/target/src/conf/sitemaps/admin.sitemap': File '/var/packages/openHAB2/target/src/con
f/sitemaps/admin.sitemap' cannot be read.
java.io.IOException: File '/var/packages/openHAB2/target/src/conf/sitemaps/admin.sitemap' cannot be read
    at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:251)[30:org.apache.commons.io:2.2.0]
    at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:239)[123:org.eclipse.smarthome.model.core:0.9.0.201703201701]
    at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:308)[123:org.eclipse.smarthome.model.core:0.9.0.201703201701]
    at org.eclipse.smarthome.core.service.WatchQueueReader.run(WatchQueueReader.java:209)[99:org.eclipse.smarthome.core:0.9.0.201703201701]
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-03-30 13:59:58.675 [ERROR] [.core.internal.folder.FolderObserver] - Error handling update of file '/var/packages/openHAB2/target/src/conf/sitemaps/admin.sitemap': File '/var/packages/openHAB2/target/src/con
f/sitemaps/admin.sitemap' cannot be read.
java.io.IOException: File '/var/packages/openHAB2/target/src/conf/sitemaps/admin.sitemap' cannot be read
    at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:251)[30:org.apache.commons.io:2.2.0]
    at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:239)[123:org.eclipse.smarthome.model.core:0.9.0.201703201701]
    at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:308)[123:org.eclipse.smarthome.model.core:0.9.0.201703201701]
    at org.eclipse.smarthome.core.service.WatchQueueReader.run(WatchQueueReader.java:209)[99:org.eclipse.smarthome.core:0.9.0.201703201701]
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-03-30 13:59:58.971 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'admin.sitemap'
2017-03-30 13:59:58.988 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'admin.sitemap'

I am editing the files directly from command line using vi.

Regards Ingo

triller-telekom commented 7 years ago

I just tried to change my sitemap using vi on the command line and immediately after saving the file the reload was successful. I have tested it with Eclipse SmartHome and also on openHAB.

What kind of linux distribution are you using? How did you install openHAB? Your folder structure /var/packages/openHAB2/target/src/conf sounds "strange", i.e. why is there a target/src in there?.

Can you reproduce the exception with a fresh installation of openHAB?

itn3rd77 commented 7 years ago

Hi,

thanks for looking into this. I am using openHAB on a Synology NAS (x86-based). openHAB is installed with a proper Synology package I maintain for myself. Synology packages install under /var/packages/<name-of-the-package>. The /target folder is a fixed folder added by the Synology installer. Within the /target folder lives the content of the package e.g. the openHAB "sources" and some other stuff.

Maybe it is a problem with symbolic links. The conf folder is a symbolic link.

I am using openHAB on my Synology NAS for over a year now and I can not remember have seen this behaviour before. It´s not a big issue as the reload is successful after the two exceptions are thrown.

With a fresh installation of the Synology package I can reproduce the exception.

triller-telekom commented 7 years ago

If I move my conf folder into conf-target and set up a symlink conf pointing to conf-target and then edit my sitemap with vim on the console, the reload is successful for me without any exception.

Is your symlink pointing to a different file-system, maybe on NFS where it is sometimes not available?

itn3rd77 commented 7 years ago

The symlink is pointing to a Btrfs-Volume which is on the same physical hard disk.

kaikreuzer commented 7 years ago

From the code I can see that this exception is thrown when "canRead" is checked on a file. As you seem to have 4 subsequent notifications from the OS, I would assume that the OS updates the file in multiple steps and not as a single transaction. I could imagine that this is caused by editing a file through Samba, so that the Samba server actually ajusts the file permissions only after writing the file.

There isn't really much we can do about it. But I think we definitely should not log an error including stacktrace in such a case. My suggestion would be to reduce this to a warning and remove the stacktrace - this would be less intrusive, but still inform the user that something fishy is going on in the file system.

itn3rd77 commented 7 years ago

I'am fine with that. Just wanted to bring this to your attention.