Repository navigation
Conversation
The notify watcher watched the project with notify's default config, which follows symlinks. inotify has one watch per directory, however many paths lead to it, and notify reports a directory's events under whichever of those paths it walked last. So with a symlink `link -> a`, a change to `a/f` could be reported as a change to `link/f`. Nothing depends on `link/f`, because buck2 reads a symlink's target by the target's own path, so the daemon kept its stale copy of `a/f` until it was restarted. Each directory is now watched only by its own path, as watchman does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D133488702. (Because this pull request was imported automatically, there will not be any future comments.) |
This branch has not been deployed
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.
Summary
With the default
notifyfile watcher, the daemon can stop noticing changesin a directory that a symlink inside the project also leads to. Builds then
use stale sources until the daemon is restarted.
The watcher watches the project recursively with notify's default config,
which follows symlinks. inotify has one watch per directory, however many
paths lead to it: adding a watch for a directory that is already watched
returns the same watch descriptor. notify keeps one path for each
descriptor, the one it walked last. So if the project has
link -> aandnotify walks
linkaftera, every later event inais reported underlink. A change toa/farrives as a change tolink/f. Nothing depends onlink/f, because buck2 reads through a symlink by its target's own path, soDICE keeps its old copy of
a/f.Whether a directory is affected depends on the order of the initial walk,
so it looks random to users. Restarting the daemon fixes it, because a new
daemon reads everything again. notify 9 still keeps one path per descriptor,
so the update to 9.0.0-rc.6 doesn't change this.
This change turns off
follow_symlinks, so each directory is watched only byits own path. A symlink's target inside the project is watched where it is.
Watchman doesn't follow symlinks either, so both watchers now behave the
same. A side effect is that the watcher no longer watches directories outside
the project that symlinks point to. buck2 never acted on those events, since
it doesn't track changes behind external symlinks.
Reproduction
We hit this in GHC's source tree. Its
configurelinks two librarydirectories into another package's directory, so edits to one of those
libraries were missed until
buck2 kill.Test plan
change_behind_symlink_is_reported_under_real_path, for Linux.It watches a directory with 16 symlinks to it, changes a file in the
directory, and checks that the event names the file's real path. With
with_follow_symlinks(true)it fails every time, and the change isreported as
links2/a/f.cargo test -p buck2_file_watcher --lib notify: all 6 tests pass.build prints v2, and the event log shows a change to
a/y.txt.🤖 Generated with Claude Code