-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix flakiness on TestFilestreamMetadataUpdatedOnRename #42221
Open
belimawr
wants to merge
3
commits into
elastic:8.x
Choose a base branch
from
belimawr:FixflakinessonTestFilestreamMetadataUpdatedOnRename-8.x
base: 8.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
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.
Could this be a bug with the file system watcher implementation? AFAIK rename is atomic on Linux.
The man page says:
For this limitation the file watcher should have a debounce mechanism to avoid changing states multiple times within a short period.
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.
I saw this bit of the man page, however, my understanding is that it is atomic only when "newpath" already exists:
The documentation makes no statement about the behaviour when "newpath" does not exist.
We kinda have a debounce approach, we only check the file system once every 10s (default value for
prospector.scanner.check_interval
), at that point we list the files pointed by the glob, then diff it with our current list of files being harvested, if the file is not in the file system but is in our list, then the file has been removed.There hasn't been any significant change on the file watcher in a while. It is curious this started happening how.
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.
How are we sure that this happens only in testing and our customers don't face the same issue running in production?
If our customers experience the same issue on their environments, it's not a flaky test it's a bug in our implementation that needs to be fixed.
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.
Honestly, we don't know. If that happens on a user's deployment, the observable effect will be data duplication of that specific file, which is not a good outcome, but at least it is not data loss.
One particularity of this test, which is very likely what makes it flaky, is the fact that
prospector.scanner.check_interval
is set to1ms
. Our docs are clear: we do not recommend using values< 1s
. The reason for that is that most file systems track modification times in seconds, so scanning faster than that can have unexpected results.Honestly, if in a real production environment, if a rename operation is taking more than
10s
(the default value), there are likely bigger problems happening there.I do not believe it's a bug with our implementation, we take a "snapshot" of the files (well, the globs defined in
paths
) and compare it with the list of files we know. If the file is not on the file system, but it is on our list, it has been removed. There isn't much more (if anything) that we can do without getting into the inner workings of the Kernel and file system. We have reasonable defaults and document possible pitfalls users might fall into. Our implementation also behaves the same across all OSes and file systems.Even inotify does not handle renames directly:
Which is pretty much the issue this PR is circumventing.
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.
Could be wrong but isn't this a limitation of how the native ID interacts with inode re-use? In which case the "fix" is to use fingerprint which shouldn't be getting confused about a rename.
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.
This case has nothing to do with inode reuse, I manually validated that. The file is correctly renamed, inode is preserved, the content is preserved, etc. I did some tests of quickly deleting and creating a different file and the inodes are never re-used.
The problem is that when we resolve the glob, none of the files are there, neither the original, nor the "destination".
With a
prospector.scanner.check_interval
so small, there is a small chance that when we resolve the glob, it resolves to nothing, but then late the renamed file appears.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.
OK. So I misunderstood the comment about inodes. Maybe we should add to the
prospector.scanner.check_interval
docs this possibility.