fix: batch pushes by size, not just row count (#8)
A 500-row batch of content-heavy observations exceeded the receiver's 4 MiB body limit and returned 400, so the sender retried the same batch on every sweep and the log stalled. Pushes now trim to a 2 MiB budget (rows are ordered by HCL, so the tail simply arrives next time) and the receiver accepts up to 8 MiB.
This commit is contained in:
@@ -289,7 +289,7 @@ func TestHandleBatchRejectsOversizedBatch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleBatchRejectsHugeBody: an oversized body (beyond the 4 MiB cap)
|
||||
// TestHandleBatchRejectsHugeBody: an oversized body (beyond maxBatchBody)
|
||||
// must be refused even when the row count is small.
|
||||
func TestHandleBatchRejectsHugeBody(t *testing.T) {
|
||||
b := tmpKnoxDB(t)
|
||||
@@ -300,7 +300,7 @@ func TestHandleBatchRejectsHugeBody(t *testing.T) {
|
||||
rows := []db.GossipObservation{{
|
||||
NodeID: "0123456789abcdef0123456789abcdef", HCL: 1,
|
||||
Fingerprint: "fp:huge", SourceID: "test", Title: "t",
|
||||
Summary: strings.Repeat("x", 5<<20), // 5 MiB summary
|
||||
Summary: strings.Repeat("x", 9<<20), // 9 MiB, past maxBatchBody
|
||||
CollectedAt: "2026-08-29T00:00:00Z",
|
||||
}}
|
||||
body, _ := json.Marshal(rows)
|
||||
|
||||
Reference in New Issue
Block a user