Repository navigation
Watch directories created before their parent's watch landed - #1558
Merged
Merged
Conversation
Routes every directory watch through watch_tree, which still walks once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1557
On inotify each directory gets its own watch. When a directory appears, the watcher walked it once and then watched what the walk found. A subdirectory created after that walk but before its parent's watch landed got no event and was never watched, so every later write inside it was lost.
mkdir -p a/b/cracing the watcher's thread (easiest to hit pinned to one CPU) does exactly that.Red commit first:
watch_tree_watches_a_directory_created_before_its_parent_was_watched(unit test,packages/rust/src/watcher.rs).The fix:
watch_treewalks the new directory again after watching what it found, and stops once a walk finds nothing unwatched. A walk that finds nothing new costs one extra read of the new tree.Hand test (
dirsql server, all processes pinned to one CPU,mkdir -p dN/a/b/c/d/e/f/gthen writer.jsonat the bottom, 200 times per run, 4 runs): before, 3 of 800 writes produced no event; after, 0 of 800.E2E Verification
pnpm test:e2e-- passedcargo test -p dirsql --features cli-- all passedpackages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python)packages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts)testing-conventions e2e attest 'uv run python -m pytest tests/e2e/watch_speed_test.py tests/e2e/jsonl_parse_speed_test.py tests/e2e/on_file_query_test.py tests/e2e/fanout_test.py -q';testing-conventions e2e attest 'pnpm test:e2e'watch_speed_testis flaky around its 1.1x bar on this host with and without this change (unfixed core failed 3 of 3, this branch passed 2 of 3); it measures writes to an existing file, a path this change does not touch.Changelog / Migrations
<root>/<pkg>/changelog.d/for each changed package (or:skip-changelogtrailer on a commit with reason)<root>/<pkg>/migrations.d/for each changed package (every subsection but Summary_None._when nothing breaks)