Skip to content

mimirpb: fix RW2 write request splitting - #16295

Open
aknuds1 wants to merge 1 commit into
mainfrom
arve/fix-rw2-write-request-splitting
Open

mimirpb: fix RW2 write request splitting#16295
aknuds1 wants to merge 1 commit into
mainfrom
arve/fix-rw2-write-request-splitting

Conversation

@aknuds1

@aknuds1 aknuds1 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What this PR does

It follows the Remote Write 2.0 Kafka record-splitting pattern introduced in #12166 and fixes the split size calculation. The splitter previously counted a series' protobuf message payload but omitted the surrounding field key and length prefix when deciding whether another series fit. Requests containing multiple series near the configured producer record limit could therefore still exceed it.

The splitter now includes that embedded-message framing, preserves write-request settings across generated requests, returns the original request for non-positive limits, and caps its initial allocation at the number of series. As before, splitting is best-effort: a single series larger than the limit remains intact and may produce an oversized record.

Checklist

  • Tests updated.
  • Documentation added. Not applicable: this is an internal correctness fix with no configuration or user-facing API changes.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features. Not applicable: this PR doesn't add an experimental feature or configuration surface.

@aknuds1
aknuds1 force-pushed the arve/fix-rw2-write-request-splitting branch from 761a41c to 9254f43 Compare August 4, 2026 16:24
@aknuds1
aknuds1 force-pushed the arve/ruler-split-remote-distributor-writes branch 7 times, most recently from b7df148 to e3e3ac8 Compare August 5, 2026 07:44
aknuds1 added a commit that referenced this pull request Aug 5, 2026
<!--  Thanks for sending a pull request!  Before submitting:

1. Read our CONTRIBUTING.md guide
2. Rebase your PR if it gets out of sync with main
-->

#### What this PR does

Remote ruler writes were previously sent as a single gRPC message, so
large rule evaluation results could exceed
`ruler.distributor.grpc_client_config.max_send_msg_size`. This PR
derives a compression-safe effective payload limit, splits oversized
Remote Write 1.0 requests at series boundaries, and sends the resulting
requests sequentially. Each generated request has its own timeout and
retry lifecycle.

Successful earlier requests aren't rolled back if a later request fails,
so a failed rule evaluation can leave partially written results. The
ruler emits one float or native-histogram sample per result series for
each evaluation. Consequently, an individual result series exceeding the
effective split limit cannot be losslessly subdivided. If this occurs,
increase `ruler.distributor.grpc_client_config.max_send_msg_size` and
configure the distributor's `server.grpc_server_max_recv_msg_size` to be
at least as large. When compression is enabled, a series above the
conservative effective limit may still succeed if its compressed payload
fits within the configured transport limit; otherwise gRPC returns
`ResourceExhausted`.

The implementation preserves request ownership and series ordering and
reuses the RW1 write-request splitter already used by ingest storage to
keep Kafka records within their configured size limit. The ruler adds
compression-aware sizing, sequential gRPC sends, and per-request retries
around that splitter. The
`cortex_ruler_remote_distributor_requests_per_write_request` histogram
reports how many remote requests each ruler write generates. This PR
also fixes the RW1 splitter's protobuf embedded-message framing
accounting and caps its initial preallocation for very small limits. The
corresponding RW2 fixes are in #16295.

#### Checklist

- [x] Tests updated.
- [x] Documentation added.
- [x] `CHANGELOG.md` updated - the order of entries should be
`[CHANGE]`, `[FEATURE]`, `[ENHANCEMENT]`, `[BUGFIX]`. If changelog entry
is not needed, please add the `changelog-not-needed` label to the PR.
- [ ]
[`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md)
updated with experimental features. Not applicable: this PR doesn't add
an experimental feature or configuration surface.

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Julius Hinze <julius.hinze@grafana.com>
Base automatically changed from arve/ruler-split-remote-distributor-writes to main August 5, 2026 14:36
Account for protobuf embedded-message framing when splitting Remote Write 2.0 requests, preserve request settings, and bound capacity estimates for small size limits.
@aknuds1
aknuds1 force-pushed the arve/fix-rw2-write-request-splitting branch from 9254f43 to 92ec5a3 Compare August 5, 2026 14:54
@aknuds1
aknuds1 marked this pull request as ready for review August 5, 2026 14:57
@aknuds1
aknuds1 requested a review from a team as a code owner August 5, 2026 14:57
@aknuds1 aknuds1 added bug Something isn't working ingest-storage Kafka based ingest storage architecture labels Aug 5, 2026
@aknuds1
aknuds1 requested a review from juliusmh August 5, 2026 14:58
@pitasi

pitasi commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

please rebase this PR on latest main, otherwise it can't merge — it's blocked on required checks that will never report.

context: #16335 changed the unit test CI matrix and the required checks got renamed (test (N, 10)test (N, 5)). CI runs from before that change only report the old names, so the branch needs to pick up the new workflow from main. sorry for the churn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ingest-storage Kafka based ingest storage architecture

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants