mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-03-15 12:27:30 +01:00
fix: Fix metricstore memory explosion from broken emergency free and batch aborts
- Fix MemoryUsageTracker: remove premature bufferPool.Clear() that prevented mem.Alloc from decreasing, replace broken ForceFree loop (100 iterations with no GC) with progressive time-based Free at 75%/50%/25% retention, add bufferPool.Clear()+GC between steps so memory stats update correctly - Enable debug.FreeOSMemory() after emergency freeing to return memory to OS - Add adaptive ticker: 30s checks when memory >80% of cap, normal otherwise - Reduce default memory check interval from 1h to 5min - Don't abort entire NATS batch on single write error (out-of-order timestamp), log warning and continue processing remaining lines - Prune empty levels from tree after free() to reduce overhead - Include buffer struct overhead in sizeInBytes() for more accurate reporting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 7ce28627fc1d
This commit is contained in:
@@ -408,3 +408,12 @@ func (b *buffer) count() int64 {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// bufferCount returns the number of buffer nodes in the linked list.
|
||||
func (b *buffer) bufferCount() int64 {
|
||||
var n int64
|
||||
for ; b != nil; b = b.prev {
|
||||
n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user