Measure each item its own way; never compare a partial size (hq ADR 0233)
A walk over a large library every hour loads the array that protects it. An item now says how it is measured — a bounded daily walk, a dataset's counters, or its top level only — and a size that is a lower bound is kept as such and never read as a shrink.
This commit is contained in:
@@ -107,3 +107,24 @@ func TestReadingsAreHourlyAndThePeakIsTheLargest(t *testing.T) {
|
||||
t.Fatalf("the newest measurement is not the one on record: %+v", r)
|
||||
}
|
||||
}
|
||||
|
||||
// A partial walk's lower bound is kept as the newest measurement, said as partial, and never kept as a
|
||||
// reading a shrink would be read against.
|
||||
func TestAPartialMeasurementIsNeverAReading(t *testing.T) {
|
||||
inv := fresh(t)
|
||||
ctx := t.Context()
|
||||
now := time.Date(2026, 10, 6, 0, 0, 0, 0, time.UTC)
|
||||
declared := []DeclaredData{{Module: "big", Item: "data", Class: "valuable", Owned: true}}
|
||||
if _, err := inv.RecordData(ctx, "home", declared, map[string]map[string]Measurement{"big": {"data": {
|
||||
Path: "/srv/big", Size: size(5), MeasuredAt: at(now), Precision: "partial: stopped"}}}, "", now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var n int
|
||||
if err := inv.store.Pool().QueryRow(ctx, `select count(*) from data_reading`).Scan(&n); err != nil || n != 0 {
|
||||
t.Fatalf("%d readings from a partial measurement: %v", n, err)
|
||||
}
|
||||
r, err := inv.DataOf(ctx, "home", "big", "data")
|
||||
if err != nil || r.Precision != "partial: stopped" || Comparable(r.Precision) {
|
||||
t.Fatalf("%+v, %v", r, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user