Commit 5bddeba
committed
keyviz: clamp HistoryColumns to MaxHistoryColumns upper bound
Round-1 review fix for PR #651 (Gemini medium):
newRingBuffer pre-allocates a slice of capacity HistoryColumns at
construction. A misconfiguration like --keyvizHistoryColumns=100000000
(operator typo) would reserve gigabytes upfront and likely OOM the
node before the heatmap returned its first column.
Add MaxHistoryColumns = 100_000 (~70 days at 60s Step) and clamp
opts.HistoryColumns in NewMemSampler so excessive values silently
land at the cap instead of being trusted as-is. The cap lives in the
keyviz package (next to the existing Default* constants) because the
risk is a property of the data structure, not the caller.
Operators wanting longer retention should use the Phase 3 persistence
path (per-Raft-group `!admin|keyviz|*` namespace) — not a giant
in-memory ring.
Test TestHistoryColumnsClampedAboveMax confirms both above-cap input
clamps to MaxHistoryColumns and exactly-at-cap input is preserved.1 parent 88423f6 commit 5bddeba
2 files changed
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
| |||
303 | 312 | | |
304 | 313 | | |
305 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
306 | 318 | | |
307 | 319 | | |
308 | 320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
869 | 869 | | |
870 | 870 | | |
871 | 871 | | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
872 | 897 | | |
873 | 898 | | |
874 | 899 | | |
| |||
0 commit comments