-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
Inotify event order/duplication, fix #117 and #233 #375
Conversation
- This is related to gorakhargosh#117 and gorakhargosh#233 - It's about a single path that is has 2 wd values, i.e., a subdirectory path that was created again before the "bookkeeping removal" event (IN_IGNORE) of a deletion was processed - The test is using a stochastical approach to reach the bug, in the sense that being "fast" isn't enough to enforce a particular event order; however, a "lucky" event synchronization seems extremely rare and the package should pass on every case - Even with an unknown order for the events, the test is counting and enforces: - Watchdog emits the 120 events that happened - Specific number of events for each type - Order constraing as required for minimal consistency (e.g. not deleting a directory that wasn't created)
- The call on inotify_event.is_ignored was removing the wrong wd, due to another wd with the same path (self._wd_for_path[src_path] was replaced) - Fix gorakhargosh#117 and gorakhargosh#233 - Still not enough to fix every bug regarding fast/unordered events, but doesn't crash anymore
c = IN_CREATE|IS_DIR d = IN_DELETE|IS_DIR ds = IN_DELETE_SELF i = IN_IGNORE These are inotify events, not watchdog events The new test is written in a new module because it required a different teardown function to stop the emitter before undoing the mock
Inotify emits a IN_DELETE|IS_DIR event and a IN_DELETE_SELF event (in this order) when a watched directory is removed, the former event happens for all directories and generates a pair of a DirDeletedEvent and a DirModifiedEvent instances, the latter used to generate a (duplicated and unrequired) DirDeletedEvent With this change, the test_fast_subdirectory_creation_deletion no longer fails
I'm testing this with #368. Before pushing, I've checked that the tests are passing on all environments. Commands like |
Since 17 Aug, this fix is also in a patch applied by dose to use watchdog. |
I wonder why no one commented on this PR yet. |
Thank you for spending the time to fix these issues. Sorry that we took so long to get around to answering, I didn't know I was the only one looking at these. |
Inotify event order/duplication, fix gorakhargosh#117 and gorakhargosh#233
Add 2 new tests that addresses #117 and #233, fix them and fix a
DirDeletedEvent
duplication found on Linux when deleting a directory:observers.inotify_c.Inotify._remove_watch_bookkeeping
helper method, as it would mixwd
andsrc_path
when removing a path that was assigned to more than onewd
. The items on thewd
to/fromsrc_path
mappings are still being removed, but consistently and inlined;DirDeletedEvent
was emitted twice as both theIN_DELETE|IS_DIR
event and theIN_DELETE_SELF
event were triggering a watchdog event, that was fixed by removing the latter event;IN_DELETE_SELF
, mocking the Inotify API for that. This test doesn't depend on randomness/speed). The mock/monkeypatch required another test module to properly stop the emitter.The
IN_DELETE_SELF
is a directory-only event, so this inotify event doesn't have anIS_DIR
flag. The former code that evaluatedcls = DirDeletedEvent if event.is_directory else FileDeletedEvent
on such an event is an evidence that it wasn't being tested.