Skip to content

fix: batch pushes to stay under the request size cap - #49

Merged
shreekarshetty merged 2 commits into
developfrom
shreekar/vmpush-batch-snapshot-push
Aug 20, 2026
Merged

fix: batch pushes to stay under the request size cap#49
shreekarshetty merged 2 commits into
developfrom
shreekar/vmpush-batch-snapshot-push

Conversation

@shreekarshetty

@shreekarshetty shreekarshetty commented Aug 20, 2026

Copy link
Copy Markdown

Summary

readiness never passing because the post-backfill snapshot push to VM was 79MB+, over the 32MB limit.
splits Push into 20k-series batches so it stays well under that.

Claude details

Root cause: converge/runner.go's pushSnapshot calls eng.Snapshot() (one Sample per active counter chain entry) and sends it all in a single vmpush.Sink.Push() call, which builds one prompb.WriteRequest and issues one POST. In prod, a 3h backfill window across 5 zones produced 758,937 series in one request (79.2MB unpacked), well past VM's -maxInsertRequestSize=33554432 (32MB) cap. Since chains only evict after a successful push, the failure was retried every tick with a growing payload, and readiness (gated on push success by #46) never passed.

Fix: Sink.Push now splits samples into batches of maxBatchSeries (20,000) before marshaling/sending each as its own request. At the ~104 bytes/series observed in prod logs (79,197,833 bytes / 758,937 series), 20k series is ~2MB unpacked — about 16x under the cap, with headroom for label-cardinality variance across zones/metrics. No caller changes needed; pushSnapshot and any other Push() call site benefit automatically.

Testing:

  • Added TestPushSplitsIntoBatchesUnderCap in vmpush/sink_test.go: spins up an httptest.Server, pushes 2*maxBatchSeries + 1 samples, asserts 3 requests are issued and no single request exceeds maxBatchSeries series (decoding each request's snappy+protobuf body to check).
  • Full test suite passes (go test ./...), go vet ./... clean, go build ./... clean.

Not in scope: a separate recurring error (error unmarshaling zone plan for zone ...: unexpected end of JSON input, every ~1min across all 5 prod zones) was also observed in the same logs while debugging this. It doesn't block readiness and looks unrelated to the batching issue, but is untriaged — tracked separately, not fixed here.

⚡ Built with Claude Code

Post-backfill snapshots in prod carry enough series to blow past VM's
32MB request limit in one push, which stalls readiness indefinitely.
Push now splits into batches of 20k series.
@shreekarshetty shreekarshetty changed the title fix: batch VM remote-write pushes to stay under the request size cap fix: batch pushes to stay under the request size cap Aug 20, 2026
@shreekarshetty
shreekarshetty marked this pull request as ready for review August 20, 2026 14:39
@shreekarshetty
shreekarshetty requested a review from a team as a code owner August 20, 2026 14:39
@shreekarshetty
shreekarshetty enabled auto-merge (squash) August 20, 2026 14:39

@sprsquish sprsquish left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would slices.Chunk work in this case?

@shreekarshetty
shreekarshetty merged commit 3d87fdc into develop Aug 20, 2026
6 checks passed
@shreekarshetty
shreekarshetty deleted the shreekar/vmpush-batch-snapshot-push branch August 20, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants