Repository navigation
catalog: add memory and swap columns to console utilization views - #39034
Conversation
6e6f3c1 to
7ec45f5
Compare
7ec45f5 to
355b35a
Compare
jdonelson
left a comment
There was a problem hiding this comment.
The same points as my previous review, anchored to lines.
Reviewed with the stacked RAM/swap chart in mind, since that's the consumer. The single shared denominator is the right call: bar, stacked band and ceiling on one axis, no client-side byte arithmetic. Measuring the argmax alternative before rejecting it is the right way to settle that trade.
One thing worth stating explicitly somewhere in the code: these are worst-process shares, not replica totals. Identical at scale=1, but on multi-process sizes they answer "the worst process is at 98% of its own allocation" rather than "the replica is at 32% overall". That's the better number for a chart with a limit line, but a consumer reading ram_percent will otherwise assume a replica total.
Holding only on the value test.
| -- upper bound rather than an observed state. Selecting them row-consistently | ||
| -- would need an argmax over processes, which costs a top-k and a join in | ||
| -- every one of these indexed views. | ||
| MAX(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0) AS ram_percent, |
There was a problem hiding this comment.
Blocking: no test covers these values.
test_smoketest_all_builtins checks the declared RelationDesc against the SQL's output columns, and the regenerated goldens are plan text. Neither asserts a number. Switching MAX to SUM here, or dropping the per-process denominator, leaves every test green while silently undoing the argument this PR makes.
The introspection source can't be populated deterministically, but the arithmetic can be exercised over a table shaped like it: single process, several processes with a skew, NULL swap_bytes, NULL heap_limit, zero denominator. That pins the two decisions most likely to get "simplified" later by someone who hasn't read the description.
There was a problem hiding this comment.
Added test/sqllogictest/console_cluster_utilization_shares.slt: the three expressions over tables shaped like the metrics relation, asserting actual numbers for a single process, skew with both peaks on one process, skew in opposite directions, NULL swap_bytes, NULL heap_limit, and a zero denominator.
I mutation-tested it rather than trusting it: flipping MAX to SUM moves r2 from 0.9 to 1.2 and the file fails. It also pins the per-process denominator (multiplying by the process count would give 0.45), and asserts that r3 — skewed in opposite directions — stacks past its own heap ceiling, so the independent-maxima behaviour is a checked property rather than only a comment.
| -- would need an argmax over processes, which costs a top-k and a join in | ||
| -- every one of these indexed views. | ||
| MAX(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0) AS ram_percent, | ||
| MAX(m.swap_bytes::float8) / NULLIF(s.memory_bytes, 0) AS swap_percent, |
There was a problem hiding this comment.
swap_percent now names two different quantities.
The notes cover the scaling difference from mz_cluster_replica_utilization.swap_percent (fraction here, 0..100 there) but not the larger one: that column divides by heap_limit, this one by a process's RAM allocation. Same column name, different denominator, different relation.
A column comment on at least one side would help. swap_of_ram_percent would remove the ambiguity outright.
There was a problem hiding this comment.
Renamed to swap_of_ram_percent. You are right that the denominator difference is the bigger one and I had only flagged the scaling.
Worth noting for anyone reading later: the first rename attempt matched four occurrences, two of them the pre-existing mz_cluster_replica_utilization columns. Those are untouched.
| -- every one of these indexed views. | ||
| MAX(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0) AS ram_percent, | ||
| MAX(m.swap_bytes::float8) / NULLIF(s.memory_bytes, 0) AS swap_percent, | ||
| MAX(m.heap_limit::float8) / NULLIF(s.memory_bytes, 0) AS heap_limit_percent |
There was a problem hiding this comment.
With these three present, heap_percent becomes derivable: (ram_percent + swap_percent) / heap_limit_percent reproduces it exactly.
It's pre-existing and in use, so removing it is out of scope here. Worth a note so a fourth spelling of the same quantity doesn't appear later.
There was a problem hiding this comment.
Noted in the shared doc comment, but not as "exactly" — I do not think that holds. heap_percent is MAX(heap_bytes / heap_limit), a max of a ratio over one process, while these three are independent maxima. They agree at scale=1 and diverge under skew, which is the same caveat this PR documents for the stack itself.
So the note reads "these recombine to heap_percent where the maxima agree, so prefer that column over a fourth spelling". Happy to drop the hedge if you read it differently, but stating it as exact would put a new wrong claim in the source.
| -- For each (replica, bucket), take the sample with the highest heap. | ||
| max_heap AS ( | ||
| SELECT DISTINCT ON (bucket_start, replica_id) bucket_start, replica_id, heap_percent, occurred_at | ||
| SELECT DISTINCT ON (bucket_start, replica_id) bucket_start, replica_id, heap_percent, ram_percent, swap_percent, heap_limit_percent, occurred_at |
There was a problem hiding this comment.
Attaching the three new columns to max_heap means they're reported from the peak-heap sample, so a bucket's ram_percent is not that bucket's peak RAM.
That's the right choice for a memory chart, but it's unstated. A reader comparing against max_memory will find the discrepancy and have to work out which one is wrong. One line in the comment above covers it.
There was a problem hiding this comment.
Added to the comment above max_heap: the RAM and swap shares ride along, so they describe that sample rather than the bucket peak RAM, which is what max_memory reports.
| MAX(m.heap_bytes::float8 / NULLIF(m.heap_limit, 0)), | ||
| SUM(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0) / NULLIF(s.processes, 0) | ||
| ) AS heap_percent, | ||
| -- Worst-process shares of that process's RAM allocation, so they stack on |
There was a problem hiding this comment.
nit: this eight-line block is duplicated verbatim from the binned body. CLAUDE.md's "every fact gets exactly one owning comment" suggests one owner and a pointer from the other.
There was a problem hiding this comment.
Fixed — folded back into a single CONSOLE_MEMORY_SHARES_SQL const interpolated into both bodies.
This was a regression on my side: it was a shared const earlier, and I reintroduced the duplication when I rebuilt the columns for the RAM-denominated design.
| -- would need an argmax over processes, which costs a top-k and a join in | ||
| -- every one of these indexed views. | ||
| MAX(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0) AS ram_percent, | ||
| MAX(m.swap_bytes::float8) / NULLIF(s.memory_bytes, 0) AS swap_percent, |
There was a problem hiding this comment.
nit: the null-rather-than-zero behaviour for swap-disabled sizes is a deliberate choice and a good one, but it lives only in the PR description. That's the kind of thing a later reader helpfully "fixes" with COALESCE(..., 0), turning "this size has no swap" into "this size swapped nothing".
There was a problem hiding this comment.
Added as a NOTE: on the shared fragment: null, not zero, where a size cannot swap or heap_limit goes unreported, since coalescing would report "swapped nothing" for "cannot swap". The new SLT asserts it too, so a COALESCE(..., 0) now fails a test rather than only contradicting a comment.
355b35a to
afa298e
Compare
The console utilization views expose no swap metric, so the swap data that shipped in v26.43.0 on mz_cluster_replica_metrics cannot reach the cluster utilization graphs, which read these indexed views rather than the base relations. Adds three columns to both view bodies, and so to all three indexed views: ram_percent = MAX(memory_bytes) / memory_bytes_per_process swap_of_ram_percent = MAX(swap_bytes) / memory_bytes_per_process heap_limit_percent = MAX(heap_limit) / memory_bytes_per_process All three are denominated in a single process's RAM allocation so they share one axis: ram_percent is the bar, swap_of_ram_percent stacks on top of it, and heap_limit_percent marks where RAM plus swap runs out, above 1.0. A replica that is spilling therefore draws above the 100% RAM line, which is the state the existing columns cannot express. swap_of_ram_percent is spelled out rather than named swap_percent because mz_cluster_replica_utilization already has a swap_percent, and that one divides by heap_limit rather than by the RAM allocation. They aggregate across processes with MAX rather than SUM, joining heap_percent rather than cpu_percent and memory_percent. A replica dies when any one process is OOM-killed, not when its average crosses a limit, so on a multi-process replica a SUM would draw a bar well below a limit the replica is actually crossing. Swap is what happens at that limit, so the same reasoning that made heap_percent a worst-process metric applies here. Peak RAM and peak swap are taken as independent maxima. On a skewed multi-process replica they can describe different processes, making the stacked total an upper bound rather than an observed state. Selecting them row-consistently needs an argmax over processes, which measured at +6 operators and +3 arrangements in each of the three indexed views on mz_catalog_server. The independent form folds into the hierarchical aggregate already present in each body, leaving operator and arrangement counts identical to before (80/20 for the binned views, 33/9 for the unbinned one). Values are fractions rather than percentages, matching the other _percent columns in these views, which the console scales client-side. console_cluster_utilization_shares.slt pins the arithmetic over tables shaped like the metrics relation, since the introspection source cannot be populated deterministically: MAX rather than SUM across processes, the per-process denominator, null rather than zero for a size that cannot swap or an unreported heap limit, and the zero-denominator guard. It also records that a skewed replica's stack can exceed its own heap ceiling, which is the documented upper-bound behaviour rather than a bug. Regenerates catalog_server_explain.slt, mz_catalog_server_index_accounting.slt, cockroach/srfs.slt (the index key's column position moves), and testdrive/explain-analyze.td. No builtin schema migration is needed: these are views, not persist-backed collections.
|
All six line comments are addressed and replied to individually. Summary, plus the one point from your review body: Worst-process vs replica total — agreed, and it was the gap.
The value test (your hold) — Mutation-tested rather than assumed: Also in this push: renamed to One place I did not follow you: Rebased onto current main. The earlier |
afa298e to
282d579
Compare
QA LLM Review1. MEDIUM --
|
|
You are right, and I had established this exact fact earlier while tracing why Fixed in #39066, since this had already merged. I took your second option rather than the join. Reading |
…39066) Follow-up to #39034, addressing the QA review finding on that PR. ### The problem `CONSOLE_MEMORY_SHARES_SQL` claims a replica size that cannot swap reports null for `swap_of_ram_percent`. The Kubernetes orchestrator does not produce that. `collect_heap_usage` returns `Some(vm_swap)` whenever `/proc/self/status` is readable, and `vm_swap` is 0 for a process with no swap — so a non-swap size reads **0**, indistinguishable from a swap-enabled replica sitting idle. Null means no sample at all: the process orchestrator, a failed clusterd usage fetch, or history rows predating the column. None of those mean "this size cannot swap". The claim was wrong in the NOTE, the commit message and the PR description of #39034, and the Console follow-up was going to be built on it. A chart gating its swap layer on null would have drawn an empty layer on every non-swap size. ### The fix `heap_limit_percent` already carries the capability signal, with no extra column and no join. `heap_limit` is `mem_limit + swap_limit` from the cgroup, so it equals the RAM allocation exactly when no swap is granted: ``` heap_limit_percent > 1.0 -> the size can swap heap_limit_percent = 1.0 -> it cannot ``` So the contract becomes: **gate the swap layer on `heap_limit_percent`, not on nullness.** Both a non-swap size and an idle swap-enabled replica report swap 0; the ceiling is what separates them. ### The test The slt asserted the old contract against a hand-built null row, so it was really testing how `MAX` propagates null, not what the views produce for a non-swap size — it passed while the property it named was false in production. It now covers the real case: `r1` can swap and is not, `r7` cannot swap, and the two are separated by the ceiling. ``` r1 0 1.25 true r7 0 1 false ``` ### The alternative I did not take Deriving the null from `swap_enabled` in `mz_internal.mz_cluster_replica_size_internal` would make the original claim true. It costs a join in each of the three indexed views on `mz_catalog_server` — which #39034 went to some length to avoid, measuring and rejecting an argmax for +6 operators and +3 arrangements per view — and it buys nothing `heap_limit_percent` does not already express. ### Release notes No user-facing release note. These views are `mz_internal` and marked `RELATION_SPEC_UNDOCUMENTED`; they exist for the Console. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The v26.44.0 release-note train, one commit per snapshot. Dates in RC snapshots are provisional until the release ships; the final snapshot sets the real dates. **rc.1** adds the `## v26.44.0` section — 6 Improvements, 3 Agent Skills, 4 Bug Fixes — and the `v26.44` row in the self-managed operator compatibility table. No Features section: nothing in this snapshot's 144 in-scope PRs rises to one. The Agent Skills section is back after five empty windows — the window `(2026-09-23T16:49:13Z, 2026-09-25T02:18:32Z]` holds 4 PRs and all 4 are published. **final** sets the real dates and adds no new bullets. Nothing shipped on the materialize side between `v26.44.0-rc.1` and the `v26.44.0` tag: `GET /compare/v26.44.0-rc.1...v26.44.0` is `ahead_by: 1`, and that one commit is the version bump, so every `rc.1` classification and all four verified flag defaults still hold at the ship tag. This train has only one RC (no `v26.44.0-rc.2` tag exists). Its two changes are: - **Real dates**: Cloud **2026-09-30**, Self-Managed **2026-10-01**, from the `v26.44.0` tag's commit date (`2026-09-30T10:50:59Z`) and `+1 day` — one day earlier than the provisional pair rc.1 carried, exactly as rc.1 predicted. Both date lines in `_index.md` and the `Release date:` in the YAML are updated. - **One cross-snapshot rewrite, not a new bullet**: [agent-skills#74](MaterializeInc/agent-skills#74) finishes the `mz-` rename that [#68](MaterializeInc/agent-skills#68) left `materialize-docs` out of. Rather than publishing a second Agent Skills bullet saying skills were renamed to `mz-`, `materialize-docs` is now `mz-docs` is folded into the existing **`mz-` skill names** bullet as another example. The rc.1 snapshot directory is left as the record of what was reviewed at the time. The final commit preserves the two Features a human editor added to this branch — **SCIM group-to-role mapping is generally available** and **Operational dashboards for Self-Managed** — and leaves the Improvements and Bug Fixes sections untouched.⚠️ **Reviewer checks** - **The hedged-reads entry has an open testing caveat — still open, and the one entry to cut if it stays open.** #39110 flips `persist_blob_hedged_get_enabled` to `true` in the code default, which is what carries the capability to Self-Managed — Cloud has served it on through LaunchDarkly since 2026-09-24. But the PR states that real GCS and Azure object stores are not yet tested (CI covers MinIO and Azurite) and that testing under [PER-120](https://linear.app/materializeinc/issue/PER-120) "should finish before this reaches self-managed users." Nothing in the `final` increment resolves this, and Linear was not reachable from that run. **If [PER-120](https://linear.app/materializeinc/issue/PER-120) has not closed, cut this entry before merging.** It is the only conditional entry in the release. - **The balancerd connection-limit entry changes the meaning of something already published.** `balancerd_max_connections` shipped an entry in v26.42.0 rc.2 describing over-limit connections as "rejected with an error". #38854 removes that: the `TOO_MANY_CONNECTIONS` response and the HTTPS 503 are gone, and a client over the limit now sees libpq's "server closed the connection unexpectedly". Anyone who built alerting on the v26.42.0 wording needs this. - **Two PRs are excluded as already published by the v26.43.0 train** — #38615 and #39029. Both merged to `main` inside the rc.1 window and were cherry-picked onto the v26.43 release branch, where that train's rc.2 snapshot published them. Accounted for in `omitted.md` under "Already published in an earlier release". - **This branch will need a rebase if the v26.43.0 docs PR merges first.** `_index.md` here still jumps from `## v26.44.0` to `## v26.42.0` — the v26.43.0 section is absent because that train's PR ([#38928](#38928)) has not merged. Whichever of the two merges second needs the rebase to get the sections in version order. - **Resolved:** rc.1's provisional dates were flagged as very likely one day high. They were — the `final` snapshot corrects them down by one day, on the tag date. **Inclusion rate is 9.7% (14/144) at rc.1**, inside the usual 5–15% band, and **20% (1/5) at `final`**, which reads high only because the denominator is five. The rc.1 denominator is dominated by dependency automation — 91 of the 142 materialize PRs are dependency bumps, 65 of them a single Dependabot fan-out of the `materialize-terraform-self-managed` modules across five `test/terraform` directories. Strip those and the materialize side is 10 included out of 49. Snapshot drafts (with PR links) in mz-skills: - rc.1: [release_notes.md](https://github.com/MaterializeInc/mz-skills/blob/main/data/mz-release-notes/v26.44.0/rc.1/release_notes.md) / [omitted.md](https://github.com/MaterializeInc/mz-skills/blob/main/data/mz-release-notes/v26.44.0/rc.1/omitted.md) - final: [release_notes.md](https://github.com/MaterializeInc/mz-skills/blob/main/data/mz-release-notes/v26.44.0/final/release_notes.md) / [omitted.md](https://github.com/MaterializeInc/mz-skills/blob/main/data/mz-release-notes/v26.44.0/final/omitted.md) **Borderline PRs omitted:** rc.1: 7 — [review borderline calls](https://github.com/MaterializeInc/mz-skills/blob/main/data/mz-release-notes/v26.44.0/rc.1/omitted.md#borderline), final: 0 — [none](https://github.com/MaterializeInc/mz-skills/blob/main/data/mz-release-notes/v26.44.0/final/omitted.md#borderline). The rc.1 borderline calls are unchanged by seeing the whole release, since `final` adds no materialize PRs. Two are still worth a reviewer's eye: #39125 (the local kind install guide moving to RustFS) — the documented Self-Managed local-kind install **fails today** for every published tag, because their `minio.yaml` references a Docker Hub repository MinIO deleted, and this is the likeliest restoration; and #39034/#39066 (the catalog half of the Console cluster-utilization memory and swap columns) — **if that Console PR shipped in this release, it belongs in the notes as a Console improvement.** Three further items are gated on flags (`enable_upsert_v2`, `enable_compute_index_peek_offload`, `enable_unified_cluster`). --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Valerie Chiang <[email protected]> Co-authored-by: Pranshu Maheshwari <[email protected]> Co-authored-by: Pranshu Maheshwari <[email protected]>
Motivation
Swap metrics shipped in v26.43.0 on
mz_cluster_replica_metrics, but the Console's cluster utilization graphs don't read that relation. They read the indexedmz_console_cluster_utilization_overview*views, which have no swap column, so the data can't reach the UI.Change
Three columns added to both view bodies, and so to all three indexed views:
All three are denominated in a single process's RAM allocation so they share one axis:
ram_percentis the bar,swap_percentstacks on top of it, andheap_limit_percentmarks where RAM + swap runs out, above 1.0. A replica that is spilling draws above the 100% RAM line — the state the existing columns cannot express.MAX rather than SUM
These aggregate across processes with
MAX, joiningheap_percentrather thancpu_percent/memory_percent/disk_percent, which areSUM.A replica dies when any one process is OOM-killed, not when its average crosses a limit. Four processes at 63/6/6/6 GiB against a 64 GiB per-process limit is 32% under SUM and 98% under MAX; the replica is killed either way. On a chart with a RAM limit line drawn on it, SUM would show a comfortable bar for a replica that is actually crossing that limit. Swap is what happens at that limit, so the reasoning that already made
heap_percenta worst-process metric applies here too. Atscale=1the two are identical, so this only changes the multi-process sizes.Cost on mz_catalog_server
Peak RAM and peak swap are taken as independent
MAXes. On a skewed multi-process replica they can describe different processes, making the stacked total an upper bound rather than an observed state.Selecting them row-consistently needs an argmax over processes (
DISTINCT ON (occurred_at, replica_id) ORDER BY heap_bytes DESC, joined back). I implemented and measured that: +6 operators and +3 arrangements in each of the three indexed views. Since idle catalog_server cost tracks operator count rather than data volume, that is a real standing charge on a shared cluster.The independent form folds into the hierarchical aggregate already present in each body —
Aggregations: max, maxbecomesmax, max, max, max, max— leaving counts identical to before:_overview_overview_24h_overview_3hIf the exact-stack semantics turn out to matter in practice, the argmax version is a contained change with a known price.
Notes for reviewers
0..1, matching the other_percentcolumns in these views, which the Console scales client-side. This differs frommz_cluster_replica_utilization, whereswap_percentis scaled in the view itself.BuiltinViews, not persist-backed collections.swap_bytesis null on replica sizes with swap disabled and on the process orchestrator, soswap_percentis null there rather than zero.heap_limithas its own null path via the/proc/meminfofallback incollect_heap_limit().heap_percent, these have no SUM fallback whenheap_limitis null; they go null instead, which seemed more honest for a chart with a limit line on it.Follow-up
A Console PR consumes these as a stacked memory/swap chart, plus a cluster-list column. It needs version-gated query builders, since the three builders in
replicaUtilizationHistory.tscurrently have none and would break on environments predating these columns.Tests
test_smoketest_all_builtinscovers this — it plans every builtin and asserts the declaredRelationDescmatches the SQL's output columns. Regeneratedcatalog_server_explain.sltandmz_catalog_server_index_accounting.slt.Release notes
No user-facing release note. These views are
mz_internaland markedRELATION_SPEC_UNDOCUMENTED; they exist for the Console.🤖 Generated with Claude Code