-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugunexpected problem or unintended behaviorunexpected problem or unintended behavior
Description
Relevant telegraf.conf
[agent]
interval = "10s"
buffer_strategy = "disk"
buffer_directory = "/home/$user/bufferTest"
[[inputs.mem]]
[[inputs.cpu]]
[[inputs.disk]]
[[outputs.file]]
files = ["/dev/null"]
Logs from Telegraf
2025-03-26T19:10:30Z D! [outputs.file] Wrote batch of 53 metrics in 264.11µs
2025-03-26T19:10:30Z D! [outputs.file] Buffer fullness: 2 metrics
System info
Telegraf 1.34.0 and commit c17467b, Linux fedora 6.13.7-200.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Mar 13 17:46:13 UTC 2025 x86_64 GNU/Linux, baremetal
Docker
The disk buffer is never truncated and therefore grows to infinity.
Unless I am mistaken, the issue seems fairly obvious in the code:
func (b *DiskBuffer) BeginTransaction(batchSize int) *Transaction {
...
offsets := make([]int, 0, batchSize)
...
offset := 0
for batchSize > 0 && readIndex < endIndex {
...
offset++
...
offsets = append(offsets, offset) // Offsets are always >= 1!
...
}
return &Transaction{Batch: metrics, valid: true, state: offsets}
}
func (b *DiskBuffer) EndTransaction(tx *Transaction) {
...
offsets := tx.state.([]int)
... // some (or all) elements of offsets are added to b.mask
if len(b.mask) == 0 || b.mask[0] != 0 { // b.mask[0] cannot be equal to 0, ever!
...
return
}
...
}
I've run telegraf 1.34.0 several times and am currently running the master branch's latest commit (as of when I am writing this). In the case of 1.34.0, I let it run for several days and the buffer grew to several tens of MBs in size, as reported by du -hd 0
. In the case of the master branch, my buffer is at 2.6 MB after roughly 10 minutes
Steps to reproduce
- Run telegraf with the included configuration file.
- Watch the disk buffer grow.
Expected behavior
The buffer grows and shrinks as data gets added and removed.
Actual behavior
The buffer grows and never shrinks.
Additional info
No response
Metadata
Metadata
Assignees
Labels
bugunexpected problem or unintended behaviorunexpected problem or unintended behavior