-
Notifications
You must be signed in to change notification settings - Fork 5.7k
fix(disk-buffer): Remove empty buffer on close #17247
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(disk-buffer): Remove empty buffer on close #17247
Conversation
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.
@srebhan This is a solid improvement over the previous version. Added a few comments in the code.
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
(cherry picked from commit 533e0a9)
Summary
When fully emptying a disk-buffer and then restarting (i.e. shutdown and start) Telegraf then empty disk-buffer still contains a (masked) metric due to restrictions in the upstream library. At runtime this is not an issue because we keep track of the empty state of the buffer and do not send the metric again. However, when shutting down Telegraf the WAL file still contains the (masked) metric but the mask and the "empty buffer" flag gets lost as it is not persisted to disk. As a consequence, we will resend the last metric even though it already has been sent.
This PR deletes the WAL file(s) when closing the empty buffer to make sure we do not send the metric again. This code can likely go away again if either tidwall/wal#31 or tidwall/wal#29 are merged.
Checklist
Related issues
related to #16981