Skip to content

compute: allow SUBSCRIBE AS OF MAX UP TO MAX#37611

Open
antiguru wants to merge 3 commits into
MaterializeInc:mainfrom
antiguru:moritz/clu-169-subscribe-as-of-max-up-to-max
Open

compute: allow SUBSCRIBE AS OF MAX UP TO MAX#37611
antiguru wants to merge 3 commits into
MaterializeInc:mainfrom
antiguru:moritz/clu-169-subscribe-as-of-max-up-to-max

Conversation

@antiguru

@antiguru antiguru commented Jul 13, 2026

Copy link
Copy Markdown
Member

SUBSCRIBE ... AS OF MAX UP TO MAX describes the empty range [as_of, up_to): as_of is inclusive and equals the exclusive up_to.
The adapter accepts it and reports the EqualSubscribeBounds notice.
It resolves to as_of = {MAX}, until = {MAX}.

Previously the empty subscribe still lowered MIR to LIR, shipped a dataflow to the cluster, installed a sink, and tore it all down to produce nothing.
The as_of = MAX, until = MAX dataflow also tripped a soft assertion in is_single_time that wrongly expected an empty until whenever as_of was MAX, which catch_unwind_optimize surfaced as internal error in optimizer.

This short-circuits the empty subscribe in implement_subscribe, where the coordinator sequencer and frontend subscribe paths converge.
When as_of == up_to it emits the initial progress row from ActiveSubscribe::initialize (WITH PROGRESS only), then closes the channel to complete the subscribe, skipping dataflow shipping and sink registration.

The wrong is_single_time assertion is removed.
is_single_time runs during MIR to LIR lowering, before the short-circuit, so the empty dataflow still reaches it.
try_step_forward(MAX) returns None, so until = {MAX} is correctly classified as not single time and until = {} (unbounded) as single time.

Fixes CLU-169

`DataflowDescription::is_single_time` asserted that an `as_of` of
`Timestamp::MAX` implied an empty `until`. That is not an invariant.
`SUBSCRIBE ... AS OF MAX UP TO MAX` describes an empty range (`as_of`
inclusive equals the exclusive `up_to`), which the adapter accepts and
reports with the `EqualSubscribeBounds` notice. It resolves to
`as_of = {MAX}, until = {MAX}`, tripping the soft assertion. Because soft
assertions panic in test and CI builds, `catch_unwind_optimize` surfaced
it as `internal error in optimizer: internal transform error`.

`MAX` is a legitimate `AS OF` / `UP TO` value. It is only unusable as the
`as_of` of a bounded single-time subscribe, where `until = as_of + 1`
would overflow. The final frontier comparison in `is_single_time` already
classifies both valid `as_of = MAX` frontiers correctly: `until = {}`
(unbounded) is single time, and `until = {MAX}` (empty range) is not. So
the assertion was both wrong and redundant, and is removed.

Adds a `mz-compute-types` unit test covering the three `is_single_time`
frontier cases, and a testdrive regression in `fetch-tail-as-of.td`.

Fixes CLU-169

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@antiguru antiguru marked this pull request as ready for review July 13, 2026 16:10
@antiguru antiguru requested a review from a team as a code owner July 13, 2026 16:10
@antiguru antiguru requested a review from frankmcsherry July 13, 2026 21:29
Comment thread test/testdrive/fetch-tail-as-of.td
A subscribe whose `as_of` equals its `up_to` covers the empty range
`[as_of, up_to)` and is guaranteed to produce no data. Previously it still
lowered MIR to LIR, shipped a dataflow to the cluster, installed a sink, and
tore it all down to yield nothing.

Short-circuit it in `implement_subscribe`, the point where both the coordinator
sequencer and frontend subscribe paths converge. When `as_of == up_to`, emit
the initial progress row that `ActiveSubscribe::initialize` produces (WITH
PROGRESS only), then close the channel to complete the subscribe, skipping
dataflow shipping and sink registration.

The `is_single_time` assertion removal stays: `is_single_time` runs during MIR
to LIR lowering, before `implement_subscribe`, so the empty subscribe would
still trip it. The assertion was wrong and redundant regardless.

Extends the `fetch-tail-as-of.td` regression with a WITH PROGRESS case that
locks the preserved progress-row contract for the short-circuited path.

Fixes CLU-169

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@antiguru antiguru requested a review from a team as a code owner July 15, 2026 02:04
The `as_of <= until` soft assertion message read "expected empty `as_of ≤
until`". The "empty" is a leftover with no meaning here. Drop it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant