Fix the origin-changes review findings
check / check (push) Failing after 2m14s

Hold the 100,000-row cap after a failed write's rows are put back, dropping and counting the oldest rows past it. Stop counts the unwritten origin changes. The prefix handler's per-write origin change limit is a field, so a test checks that one write leaves the rest. The server and README now say where origin changes come from. README, TODO and schema say 72 hours or 500 rows, whichever keeps more. The prefix page and TODO list the origin change columns and say what the peer count counts. The page takes its 5,000-row note from the constant.

Model: deepseek-v4-pro
This commit is contained in:
2026-11-05 04:33:51 +00:00
parent 347e1456a2
commit 56cfc7e554
12 changed files with 199 additions and 63 deletions
+54
View File
@@ -206,6 +206,60 @@ func TestOriginChangesDropPastTheLimit(t *testing.T) {
}
}
// TestOriginChangesPutBackTrimsToTheLimit checks that putting back what a
// failed write took, after new changes filled the table again, drops the
// oldest changes past the cap and counts them, so the cap still holds. The
// clock advances one second per change, so a change's time says its age.
func TestOriginChangesPutBackTrimsToTheLimit(t *testing.T) {
t.Parallel()
const (
limit = 100000
taken = 20000
added = 20000
)
now := time.Unix(0, 0)
table := routetable.New(routetable.Params{
Now: func() time.Time {
now = now.Add(time.Second)
return now
},
})
addr := netip.MustParseAddr("10.0.0.0")
announce := func(n int) {
for range n {
table.Announce(netip.PrefixFrom(addr, 32), asA, routeOf(peerA, asA, 10))
addr = addr.Next()
}
}
announce(limit)
takenChanges, _ := table.TakeOriginChanges(taken)
announce(added)
table.PutBackOriginChanges(takenChanges)
changes, dropped := table.TakeOriginChanges(math.MaxInt)
if dropped != added {
t.Errorf("dropped = %d, want %d", dropped, added)
}
if len(changes) != limit {
t.Errorf("len(changes) = %d, want %d", len(changes), limit)
}
// The put-back rows are the oldest, so they are the ones dropped. The
// first remaining change is the one that followed them.
if want := time.Unix(int64(added+1), 0); !changes[0].Time.Equal(want) {
t.Errorf("first change's time = %v, want %v", changes[0].Time, want)
}
}
// checkOriginChanges checks that TakeOriginChanges, taking every change,
// returns want.
func checkOriginChanges(