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

Duplicate events when editing file on Samba share #92

Open
J-N-K opened this issue Feb 26, 2023 · 7 comments
Open

Duplicate events when editing file on Samba share #92

J-N-K opened this issue Feb 26, 2023 · 7 comments

Comments

@J-N-K
Copy link

J-N-K commented Feb 26, 2023

We have found that sometimes editing files that are exposed on a samba share results in multiple create/delete events (up to six events in about half a second) instead of a single modify event.

We have now implemented a workaround in our code (openhab/openhab-core#3404) but it would be great if this could be handled here as I believe it'll be encountered by a larger audience.

@J-N-K J-N-K changed the title Duplicate events on Samba share Duplicate events when editing file on Samba share Feb 26, 2023
@gmethvin
Copy link
Owner

Are there specific types of edits that cause that behavior? Did you check if it's the underlying Java watch service that's duplicating the events or if they're generated by directory-watcher itself? (you should be able to see with debug logging enabled)

Depending on how the events are generated, we can probably detect that sequence of events in directory-watcher and compress them into a single MODIFY.

@J-N-K
Copy link
Author

J-N-K commented Feb 27, 2023

You can see example here: openhab/openhab-core#3400 (comment) (except the last post from myself, that is a bug in our code).

@gmethvin
Copy link
Owner

Which platforms have you tested on? Seems like it's either due to a bug in the underlying WatchService implementation or the events the OS itself is reporting.

@J-N-K
Copy link
Author

J-N-K commented Feb 28, 2023

For @mhilbush it is Ubuntu 22.04 for the samba server and a MacOS client. I'm not sure who actually is the issue here, if it's a faulty behavior of the client or the server.

@mhilbush
Copy link

I also see similar behavior using a Windows client (e.g. Notepad++ on Win 10) and a Linux client (nano on Ubuntu) accessing the same share as with the MacOS client.

2023-02-28 07:18:03.876 [DEBUG] [io.methvin.watcher.DirectoryWatcher ] - ENTRY_MODIFY [/opt/openhab4/conf/rules/zoneminder.rules]
2023-02-28 07:18:03.877 [DEBUG] [io.methvin.watcher.DirectoryWatcher ] - -> MODIFY [/opt/openhab4/conf/rules/zoneminder.rules] (isDirectory: false)
2023-02-28 07:18:03.877 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'zoneminder.rules'
2023-02-28 07:18:03.923 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'zoneminder.rules' is either empty or cannot be parsed correctly!
2023-02-28 07:18:03.923 [DEBUG] [io.methvin.watcher.DirectoryWatcher ] - ENTRY_MODIFY [/opt/openhab4/conf/rules/zoneminder.rules]
2023-02-28 07:18:03.924 [DEBUG] [io.methvin.watcher.DirectoryWatcher ] - -> MODIFY [/opt/openhab4/conf/rules/zoneminder.rules] (isDirectory: false)
2023-02-28 07:18:03.924 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'zoneminder.rules'

Versus saving it locally using e.g. nano.

[2023-02-28 07:39:28.275 [DEBUG] [io.methvin.watcher.DirectoryWatcher ] - ENTRY_MODIFY [/opt/openhab4/conf/rules/zoneminder.rules]
2023-02-28 07:39:28.276 [DEBUG] [io.methvin.watcher.DirectoryWatcher ] - -> MODIFY [/opt/openhab4/conf/rules/zoneminder.rules] (isDirectory: false)
2023-02-28 07:39:28.277 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'zoneminder.rules'
2023-02-28 07:39:29.909 [DEBUG] [io.methvin.watcher.DirectoryWatcher ] - ENTRY_MODIFY [/opt/openhab4/conf/rules/zoneminder.rules]

@priyankadhiman0803
Copy link

I am also getting 8 events on one event type . Like a file is deleted then 8 events are fired for it

@gmethvin
Copy link
Owner

I likely won't have time to look into this further anytime soon, but I'm happy to accept pull requests if anyone finds a viable way to handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants