-
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
[receiver/filelog] loops forever with large log lines #16487
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
@djaglowski I want to help on this if needed; for us, this is a blocker to go "GA" for our log collection through the collector. But I first like to discuss strategy. |
@alexvanboxel, I have limited capacity this week so will not be able to investigate in detail. If you have time to work out a fix, I will prioritize giving feedback. |
I'm almost afraid, that it would mean moving from Scanner to Reader, with means a lot of work. But I like a second opinion. We have had this problem for a while, so it can wait: I prefer to talk it over before beginning work. |
I think you are probably right about what it would require to fix. |
I have meet the same problem ,and find out a quick way to fix this .
` |
@djaglowski what do you think about this fix ? |
@fatsheep9146, I think this approach makes sense. @maokitty, thanks for looking into this - I'd be happy to review a PR. |
@maokitty welcome for your contribution! |
I tried to fix it without moving from |
#17301 seems not to recover the scanner? It breaks the |
The testcase |
I have created another PR using a different strategy to truncate the log entry. A scanner with the LineStartPattern may break the start line of the following log entry when truncating a long log entry. For example:
Both #17301 and #17309 use the same strategy to truncate the log and emits:
#17358 uses a double size (log_max_size * 2) buffer to avoid breaking the start line and emits:
From a user perspective, the output of #17358 may be better? 🤔 |
This brings following fixes that are related to filelog reciever: * filelogreceiver: Truncate log entry if it is longer than max_log_size ([#16487](open-telemetry/opentelemetry-collector-contrib#16487))
Component(s)
receiver/filelog
What happened?
Description
The filelog receiver loops forever if a single logline is too large. It happens at the default
1MiB
but can be reproduced when setting themax_log_size: 17Kib
on smaller lines.Steps to Reproduce
max_log_size
above the minimum of 16KiB, example :17KiB
(see example config)Expected Result
Any of the following
Actual Result
Infinite loop with
log entry too large
Collector version
v0.66.0 (but is not new...)
Environment information
Environment
OS: "Apple 13.00"
Compiler(if manually compiled): "go 1.19.1"
OpenTelemetry Collector configuration
Log output
Additional context
start_at: beginning
doesn't influence the error loop; it makes it easier to reproduce.bufio.Scanner
is used for scanning the files, a worrying note in the documentation is:Scanning stops unrecoverably at EOF, the first I/O error, or a token too large to fit in the buffer. When a scan stops, the reader may have advanced arbitrarily far past the last token. Programs that need more control over error handling or large tokens, or must run sequential scans on a reader, should use bufio.Reader instead.
The text was updated successfully, but these errors were encountered: