A Loki answer has a size cap
Systemorph/MeshWeaver#8283. On 2026-12-02 at 05:35:58Z, collection for one namespace failed on
every pass, and the incident log-collection-down-… reopened. Every query timed out after 45 s
(TaskCanceledException). The slice shrank as designed, 15 → 7.5 → 3.75 → 1.9 → 1 minute. Then it
held at its one-minute floor, still failing on the same minute, and the cursor never moved.
What the readings showed
- The window was dense, not long. In that minute, one portal pod logged about 5,240 lines and
9.7 MB. The watcher asks for up to
QueryLimit= 5,000 lines, so one page was about 9.4 MB. - Loki refused the answer, not the question. At the same moments, Loki's own log reported a
gRPC
ResourceExhaustedrefusal: the querier's result for the frontend was about 9.4 MB, against the 4,194,304-byte (4 MiB) default limit. - Size, not range. Sent by hand from inside the cluster, the same query hung past 170 s. The same minute read in 2 s slices answered in about 50 ms each, and the next 15 s window (3 MB) answered in 86 ms.
- The earlier stretches fit the same pattern. Per hour, the count of those refusals matched the collection-failure count: 11-27 18:00 → 11-28 00:00, 11-28 21:00 → 11-29 03:00, and 12-02 from 05:35. The bounded slices of Plugins#6065 could not help, because their floor is still a full minute.
The rule
A query that times out now halves the namespace's page size as well as its slice; a 429 or
5xx, which is Loki's load rather than the page's size, still narrows only the slice. The page size never drops below LogWatcherOptions.MinQueryLimit
(default 250) and is not grown back while the process runs. Smaller pages are cheap, because the
truncated-page loop reads the window on page by page within the pass budget. A page size that once
went over the cap would only fail again, and each failure costs a 45 s timeout.
Raising Loki's grpc_server_max_{send,recv}_msg_size is the server-side half. It belongs to the Loki
release's configuration, not to the watcher, and the watcher must not depend on it.
Code
src/MeshWeaver.LogWatcher/LogWatchWorker.cs (ShrinkSpan, LimitFor) and LogWatcherOptions.MinQueryLimit.
Test: src/MeshWeaver.Observability.Test/AnOversizedPageIsReadInSmallerPagesTest.cs runs a fake Loki
that times out any answer over 1,000 lines. Without the change it fails: the page stays at 5,000 lines
and no query is ever answered.