fix: batch pushes to stay under the request size cap - #49
Merged
Conversation
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.
⚡ Built with Claude Code
shreekarshetty
marked this pull request as ready for review
August 20, 2026 14:39
shreekarshetty
enabled auto-merge (squash)
August 20, 2026 14:39
sprsquish
reviewed
Aug 20, 2026
sprsquish
left a comment
Collaborator
There was a problem hiding this comment.
Would slices.Chunk work in this case?
mraerino
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'spushSnapshotcallseng.Snapshot()(one Sample per active counter chain entry) and sends it all in a singlevmpush.Sink.Push()call, which builds oneprompb.WriteRequestand 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.Pushnow splitssamplesinto batches ofmaxBatchSeries(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;pushSnapshotand any otherPush()call site benefit automatically.Testing:
TestPushSplitsIntoBatchesUnderCapinvmpush/sink_test.go: spins up anhttptest.Server, pushes2*maxBatchSeries + 1samples, asserts 3 requests are issued and no single request exceedsmaxBatchSeriesseries (decoding each request's snappy+protobuf body to check).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