Backfill observability: expose stall reason in rw_ddl_progress, and fix rw_rate_limit/rw_fragments job id column naming
Background
A user reported "MV backfill stuck at 0% forever, but only when streaming_enable_unaligned_join = true".
The actual cause had nothing to do with unaligned join: a session-level SET BACKFILL_RATE_LIMIT = 0 had been issued 4 minutes earlier and never reset. SET is connection-scoped, and the user re-ran their setup block with that line removed, reasonably assuming the old value was gone. Every subsequent CREATE MATERIALIZED VIEW on that connection got rate_limit = 0 on its scan nodes, i.e. permanently paused snapshot read.
Root-causing it required dumping 3 days of pgwire_query_log out of Loki, because nothing reachable from the symptom points at the cause. The information does exist — rw_rate_limit would have answered it in one query — but there is no path from "0%" to that table.
Two concrete gaps, both in system catalogs.
1. rw_ddl_progress gives no reason for a stall
Reproduced on main:
SET BACKGROUND_DDL = true;
SET BACKFILL_RATE_LIMIT = 0;
CREATE MATERIALIZED VIEW mv_paused AS SELECT * FROM t; -- t has 500k rows ddl_id | ddl_statement | progress | create_type
--------+-------------------------------------------------------+-----------------------------+-------------
7 | CREATE MATERIALIZED VIEW mv_paused AS SELECT * FROM t | Snapshot [0.00% (0/500000)] | BACKGROUNDThat output is byte-identical across at least five different situations:
- scan paused by
rate_limit = 0(RateLimit::Pause) - fragment waiting on a
backfill_orderdependency —BackfillOrderState::remaining_backfill_nodesinsrc/meta/src/barrier/backfill_order_control.rs LocalityProviderstill in its buffering phase waiting forStartFragmentBackfill—src/stream/src/executor/locality_provider.rs:466- cluster paused (
Mutation::Add { pause: true }) - upstream genuinely has no data, or backfill is simply slow
Meta already tracks every one of these. Proposal: add a blocked_reason (or state) column to rw_ddl_progress.
Scope should be all streaming jobs, not just MVs — a sink's backfill stalls the same way and is equally opaque today (demonstrated below).
Related but insufficient today:
rw_fragment_backfill_progressis nicer to read (carries job / upstream names) but also has no reason column.backfill_rate_limit_bytesmetric is labeled only bytable_id— no job id, fragment id, or node name, so a "which creating jobs are paused" dashboard isn't expressible.
2. rw_rate_limit.table_id and rw_fragments.table_id actually hold job ids
The Rust side is already correct — the field is typed JobId and populated from info.job_id; the proto field is literally job_id (proto/meta.proto:1126). Only the SQL-visible column name says table_id.
Same value, named differently at every layer:
| layer | name |
|---|---|
| meta model | fragment.job_id (src/meta/model/src/fragment.rs:27) |
| proto | RateLimitInfo.job_id |
| Rust field type | JobId |
| derived catalogs | rw_fragment_id_to_ddl.job_id, rw_fragment_backfill_progress.job_id |
| base table SQL column | table_id |
rw_fragment_id_to_ddl essentially exists to paper over this — its join reads on job.job_id = f.table_id and it renames the output column back to job_id.
Why it matters: silent row loss
There is no collision risk (all catalog objects share one object.oid sequence), so a bad join can't return the wrong row. But FragmentTypeFlag::rate_limit_fragments() covers backfill + source + sink fragments, so rw_rate_limit legitimately contains rows whose "job" is a sink or a source. Following the column name and joining to rw_tables / rw_materialized_views silently drops them.
Reproduced — one MV with backfill_rate_limit = 0 plus one sink with sink_rate_limit = 100:
fragment_id | fragment_type | node_name | table_id | rate_limit
-------------+---------------------------------------------------+-------------+----------+------------
3 | {MVIEW,STREAM_SCAN,SNAPSHOT_BACKFILL_STREAM_SCAN} | STREAM_SCAN | 7 | 0
4 | {SINK,STREAM_SCAN,SNAPSHOT_BACKFILL_STREAM_SCAN} | SINK | 9 | 100
4 | {SINK,STREAM_SCAN,SNAPSHOT_BACKFILL_STREAM_SCAN} | STREAM_SCAN | 9 | 0Joining to rw_relations (correct) keeps all 3. Joining to rw_tables ∪ rw_materialized_views (what the column name suggests) returns 1 row, no error, no warning — an audit of "what is rate limited" comes back incomplete with no indication that it did.
Note the third row: that sink's own STREAM_SCAN is at rate_limit = 0. The CREATE SINK statement only specified sink_rate_limit = 100; the 0 leaked in from the same session-level SET BACKFILL_RATE_LIMIT = 0. Both jobs sit at Snapshot [0.00% (...)] in rw_ddl_progress with no hint why — which is exactly gap #1, on a sink.
Proposal
- Add a
job_idcolumn torw_rate_limitandrw_fragments; keeptable_idas a deprecated alias for a release or two, since system catalogs are a public interface. - Fix both tables together — they share the identical mismatch, and fixing only one creates a new inconsistency.
- Once done,
rw_fragment_id_to_ddlcan drop its workaround join. - Consider also adding
relation_name/relation_typetorw_rate_limit, so the common case needs no hand-written join at all — as soon as one is required, someone will write it againstrw_tables.
Why one issue
Both are the same failure: the catalog holds the answer, but the symptom doesn't lead you to it, and the naming actively points the wrong way. Fixing only #1 still leaves users writing joins that silently drop sinks; fixing only #2 still leaves 0% unexplained.
Additional context
backfill_rate_limit = 0meaning pause (while-1means unlimited) is documented atsrc/common/src/session_config/mod.rs:367but is easy to invert mentally. Anotice_to_useratCREATEtime when the effective rate limit is 0 would be a cheap, separate win — happy to split that out if preferred.rw_rate_limitemits no row at all when a rate limit is unset (if let Some(rate_limit)), so "absence = unlimited". Worth documenting; it means diagnostic queries must useLEFT JOIN, notWHERE rate_limit = 0.
Source: risingwavelabs/risingwave