Skip to content
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

Open log file in append mode. #5497

Merged
merged 1 commit into from
Feb 28, 2019

Conversation

sergeykhegay
Copy link
Contributor

Problem:
When log file didn't exist the agent used to create a file without O_APPEND mode. This led to the file growing indefinitely, because the writes ignored the truncated file (by the current logrotate settings) and did not update the fd offset.

When you write to the offset bigger than the current file size, the file is expanded by the OS (at least Linux), the gap is filled with \0.

Note:
This behavior doesn't apply when the log file has already been created before Telegraf starts. The file opened in the proper append mode then.

Fix:
Always open in O_APPEND mode.

Required for all PRs:

  • [ x] Signed CLA.
  • Associated README.md updated. Not needed
  • [ x] Has appropriate unit tests.

@danielnelson danielnelson added this to the 1.10.0 milestone Feb 28, 2019
@danielnelson danielnelson added the fix pr to fix corresponding bug label Feb 28, 2019
@danielnelson danielnelson merged commit 7787ea2 into influxdata:master Feb 28, 2019
danielnelson pushed a commit that referenced this pull request Feb 28, 2019
@danielnelson
Copy link
Contributor

Thanks!

@sergeykhegay sergeykhegay deleted the fix-logging branch February 28, 2019 00:46
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
dupondje pushed a commit to dupondje/telegraf that referenced this pull request Apr 22, 2019
bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants