-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/stanza/fileconsumer] - Duplication of logs #27037
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
This is quite a rare scenario tbh. But it makes sense to fix this. |
Thanks for reporting @VihasMakwana, and especially for providing a test. I looked into this and don't believe your suggested fix would work. The problem comes down to how we handle files which we know have been rotated. Once we know a file has been rotated, we can only assess whether or not it was moved or truncated by reading a new fingerprint from the old handle. If truncated, we should not read the remainder of the file. If moved, we can read the remainder (if there is any). I've opened #27064 to address it. (One thing I dislike here is that it was necessary to save the file name on the reader, because 1/50 times running the test we would hit a nil pointer on accessing the file, which means the reader had already been closed for some reason. I am ok with this for now but I still intend to clean up the way we manage readers across the board, so that we can avoid any such concerns.) |
@djaglowski I see what you did in your PR! I kind of implemented the same in my PR here https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/25884/files#diff-a918db427e06075a5fa059d7893f54556bfa1504726ba77b3491b644a64ab818R228. But it was too lengthy. I got rid of it and used your method instead, as your method is more compact and readable. |
Component(s)
pkg/stanza
What happened?
Description
Consider the following scenario for fileconsumer:
- Write more logs to the file.
- Copy that file, move it out of the pattern, and truncate it to 0.
- Write more logs to the previous file. More than 10 lines (this is necessary)
- Call next poll()
While performing the above steps, I noticed the excess logs that we wrote (after 10 lines), were emitted twice i.e. duplicated.
Steps to Reproduce
Expected Result
It should only emit the logs once.
Actual Result
Duplication.
Proposed fix
Collector version
v0.85.0
Environment information
Environment
OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")
OpenTelemetry Collector configuration
No response
Log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: