-
Notifications
You must be signed in to change notification settings - Fork 220
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
fixes #16021 - restart inotify monitoring on queue overflow #455
Conversation
Do you want to try splitting the queues? One queue for watching the changes on the lease file, the other queue for watching |
I think the watch could be made a lot more specific actually, so instead of watching for all events in the target directory, it only watches for modifications on the lease file and moved_to events for the lease file. It could still use a single queue as the likelihood of queue exhaustion from other events in the same directory will be greatly reduced by being more specific, saving another thread and complexity. |
01d3b24
to
1062000
Compare
Updated to have specific watches for file modification and incoming moved files. This should help reduce the queue size significantly, as no longer will inotify events be generated for every single unrelated file open/read/close in the same directory. |
This breaks after leases.file is re-created by dhcpd -- no events are being caught after that. I think what's going on is that inotify_add_watch call uses the file path that was passed to it to open a file descriptor. After dhcpd re-creates the leases file, inotify continues to use the file descriptor that now points to the old copy of the leases file (dhcpd deletes it, but I think it will kick around until the fd we are holding is closed). I think on catching :move_to event the old :modify event watch should be deleted and a new one, pointing to the same path created. There is a chance that we are going to miss an update between |
1062000
to
85aca8b
Compare
Thanks, good catch! The inotify watch remains on the old inode so would need re-registering. I tried to implement the re-registering of Instead, I've reverted to the original implementation, but changed the watch on |
when :modify | ||
logger.debug "caught :modify event on #{event.absolute_name}." | ||
observer.leases_modified | ||
when :move |
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.
: moved_to 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.
Sure, updated. Both :move and :moved_to flags are present.
We could create a notifier/watcher pair per event and discard the one used for 'modify' events when the leases is recreated, but I think having re-creating 'modify' watcher is cleaner. |
inotify watches are now more specific to only monitor for modifications and incoming file moves in the directory, reducing the spurious wakeups from reads and similar events.
85aca8b
to
efba088
Compare
Yeah, recreating the whole notifier is also more complex as it'd probably have to run in a separate thread (calling its own |
@witlessbird the commit pushed is different to the current PR, it's the version that didn't re-register the :modify watcher after the inode changed. Shall I open another PR to fix that back? |
I opened #456 with the latest changes in this PR. |
seq -f "/tmp/isc/test.%g" 1 50000 | xargs touch
seems to be an effective reproducer for me, if /tmp/isc/ is the location that contains the leases file.