-
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 empty file edge case #36076
Fix empty file edge case #36076
Conversation
74e3ce4
to
1db1158
Compare
|
It's possible that file scanning happens when the file was created but was not yet written to. In this case the size is 0. We should not spawn any resources (e.g. harvesters) for such files until they actually have some content. We create events only when read something from a file, so having a harvester on an empty file is not useful. Not handling this edge case also causes our tests to be flaky, sometimes an expected size does not match an actual size (0).
1db1158
to
cc4c9c7
Compare
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.
LGTM
It's possible that file scanning happens when the file was created but was not yet written to. In this case the size is 0. We should not spawn any resources (e.g. harvesters) for such files until they actually have some content. We create events only when read something from a file, so having a harvester on an empty file is not useful. Not handling this edge case also causes our tests to be flaky, sometimes an expected size does not match an actual size (0). (cherry picked from commit 0cd5775) # Conflicts: # filebeat/input/filestream/fswatch_test.go
* Fix empty new file edge case (#36076) It's possible that file scanning happens when the file was created but was not yet written to. In this case the size is 0. We should not spawn any resources (e.g. harvesters) for such files until they actually have some content. We create events only when read something from a file, so having a harvester on an empty file is not useful. Not handling this edge case also causes our tests to be flaky, sometimes an expected size does not match an actual size (0). (cherry picked from commit 0cd5775) # Conflicts: # filebeat/input/filestream/fswatch_test.go * Resolve conflicts --------- Co-authored-by: Denis <[email protected]>
my logs now full of spam "has no content yet, skipping" for all zero size logs. And it's on the "warning" level |
It's possible that file scanning happens when the file was created but was not yet written to. In this case the size is 0. We should not spawn any resources (e.g. harvesters) for such files until they actually have some content. We create events only when read something from a file, so having a harvester on an empty file is not useful. Not handling this edge case also causes our tests to be flaky, sometimes an expected size does not match an actual size (0).
Maybe change the log level of that message to info or even debug to prevent spam? @Team |
@miksir @Alphayeeeet sorry for the log spam, addressed in #38421 |
What does this PR do?
It's possible that file scanning happens when the file was created but was not yet written to. In this case the size is 0.
We should not spawn any resources (e.g. harvesters) for such files until they actually have some content. We create events only when read something from a file, so having a harvester on an empty file is not useful.
Not handling this edge case also causes our tests to be flaky, sometimes an expected size does not match an actual size (0).
Why is it important?
To fix flaky tests and to make the code more efficient.
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Note the path placeholders you need to fix first.
touch some.log
) in/path/to/your/logs
you can see that Filebeat now detected the file, started ingestion and created an event:
fingerprint
file identity #35734