Repository navigation
Conversation
When no sample arrives, the watermark stops, and the last windows of a stream that stopped sending stay open until a sample or a barrier comes. The ingest coordinator now keeps an idle watermark: the newest sample time plus the wall-clock time since a sample last arrived, less the allowed lateness and a 1 s grace. Because it counts from the newest sample, not from the wall clock, a stream behind the wall clock (a replay) closes no window earlier than if it kept sending. Only samples ingestion keeps reset the time a sample last arrived. The coordinator checks the idle watermark every tick and, when it would close a window, flushes every shard first, so queued samples count before it. Barriers are applied before the idle close, so a window a barrier closes is not counted as closed by wall clock. The others are counted (asap_windows_closed_by_wall_clock_total); a later sample for them is late. The engine reads the wall clock through precompute::ingestion::WallClock, which tests set (manual) or stop (tests replaying past event times).
The idle watermark measured the time since a sample last arrived as the difference of two wall-clock readings, so a forward step of the system clock (NTP, a resumed VM) advanced it on a live stream and closed windows early. Each flush now reads both clocks (ClockReading): the wall-clock time still caps the watermark and the newest sample time, and the idle time is measured on WallClock::monotonic_ms (an Instant since process start, or the test's manual value). WallClock::step_wall_clock moves a test's wall clock alone.
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
…k and are stored empty
Collector windows closed only when states arrived, so while a collector
stream was idle none closed and every range over the idle period failed
("has no rows tiling", HTTP 422), for good if the stream never resumed.
As #889's idle close does for samples, a collector view's group now has
an idle watermark on the monotonic clock: the newest state's window end
(capped at its arrival's wall-clock time) plus the monotonic time since
it arrived, less the collector's close delay and skew allowance
(CollectorViewOptions::idle_close_ms, default 6 s + 2 s). Windows it
passes close with no state and are stored empty; states or corrections
of them coming later merge in (#892). Nothing closes on the clock before
a group's first states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
…k and are stored empty
Collector windows closed only when states arrived, so while a collector
stream was idle none closed and every range over the idle period failed
("has no rows tiling", HTTP 422), for good if the stream never resumed.
As #889's idle close does for samples, a collector view's group now has
an idle watermark on the monotonic clock: the newest state's window end
(capped at its arrival's wall-clock time) plus the monotonic time since
it arrived, less the collector's close delay and skew allowance
(CollectorViewOptions::idle_close_ms, default 6 s + 2 s). Windows it
passes close with no state and are stored empty; states or corrections
of them coming later merge in (#892). Nothing closes on the clock before
a group's first states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
…k and are stored empty
Collector windows closed only when states arrived, so while a collector
stream was idle none closed and every range over the idle period failed
("has no rows tiling", HTTP 422), for good if the stream never resumed.
As #889's idle close does for samples, a collector view's group now has
an idle watermark on the monotonic clock: the newest state's window end
(capped at its arrival's wall-clock time) plus the monotonic time since
it arrived, less the collector's close delay and skew allowance
(CollectorViewOptions::idle_close_ms, default 6 s + 2 s). Windows it
passes close with no state and are stored empty; states or corrections
of them coming later merge in (#892). Nothing closes on the clock before
a group's first states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem: a window closes only when the watermark passes its end. The watermark follows the newest sample (less
--allowed-lateness-ms) or an event-time barrier. When a stream stops and no producer sends a barrier, nothing moves it. The last windows of that stream then stay open, and queries over them are never answered.(30, 40]waits for a sample after 40 s. If none comes,/api/v1/query?time=40is never answered.Change: the ingest coordinator keeps an idle watermark. This is decision 5 of
docs/design/repo-layout.md(docs(design): repository layout and engine boundaries #874):t: the newest sample time, capped ata.a: when the flush that last ran a kept sample was sent.now − ais measured on the monotonic clock (Instant), so a step of the system clock does not move it.L:--allowed-lateness-ms.G: a 1 s grace.The watermark is the latest of the watermark from samples, the barrier, and the idle watermark, and it never goes back. A window
(e − W, e]therefore closes once no sample has come fore − t + L + G, which is at mostW + L + G.Effect: a stopped stream's last windows close and are answered without a barrier.
t, not fromnow.asap_windows_closed_by_wall_clock_totaland iningestion.windows_closed_by_wall_clockin/api/v1/status/asap.Review guide
chore/layout-cleanups(chore: range step cap in the query engine, one plan test helper, QueryOutcome as Result #888, b192642), stacked on fix(otlp): OTLP/HTTP replies, Prometheus resource-attribute labels, DELTA sums rejected, in-place decoder #887 → chore: pin ASAPPlanner 566b35c and its asap_sketchlib d050037 (view format 5) #886. This is a draft; do not merge.crates/precompute/src/engine.rsserve_ingest. A tick checksidle_closes_at; if it is true, all shards are flushed,aandnoware taken at that flush, and thenadvance_idleruns. Barriers are now applied beforeclose(), so a window a barrier closes is not counted as closed by wall clock.crates/precompute/src/ingestion.rs:idle_watermark_at,idle_closes_at,sample_arrived,advance_idle,event_watermark_ms, and the counter inclose_windows.afirst, so they never land in a window already closed.afor this one.a(the newShardReport::accepted_any). Unrouted, late and future samples do not, so a producer still sending other metrics does not keep the plan's stream open.flushreturns aClockReading(wall and monotonic ms). The wall time caps the watermark andtas before; the idle timenow − auses the monotonic one (WallClock::monotonic_ms, anInstantsince process start, or the test's manual value).WallClock(system, or manual for tests) replaces directwall_clock_ms()calls in the precompute engine: shard routing, flush, barrier cap and lag metrics. It is threaded throughPrecomputeOptions/EngineOptions(#[doc(hidden)]).Ingestion::advance_watermarkis deleted; its one caller usesadvance_watermark_atwith the engine's clock.WallClock::stopped(): 16 sites: 14 incrates/data-plane/tests(includingcommon::no_forward_optionsand the parity harness),test_support::options, and the precompute engine's unit-test options. Without it, a pause of more thanL + G(1 s with lateness 0) under load is taken for an idle stream. The first full gate showed exactly that:with_every_view_read_cold_the_data_plane_answers_what_the_planner_executor_answersfailed under load and passed alone.Behavior: before → after
(30, 40]never closes;query?time=40not answerede − t + L + G = 0 + 0 + 1 s); answeredsamples_dropped_late+1; the answer at 40 s is unchangedG(1 s): the idle watermark stays behind the samples' watermarkt − Lend ≤ Taunset);--stream-start-msonly marks the first window complete, as beforeL + Gwith event time slower than the wall clockInterfaces
crates/precompute/src/ingestion.rscrates/precompute/src/engine.rs,crates/data-plane/src/engine.rspub struct PrecomputeOptions { + pub clock: WallClock, } pub struct EngineOptions { + #[doc(hidden)] pub clock: WallClock, }/metrics:Tests
Three new tests in
crates/data-plane/tests/ingest_shards.rs. They use a manual clock, with no wall-clock sleeps or timing assertions; a "pass" is a barrier at 0, which closes nothing itself.the_last_window_of_a_stopped_stream_closes_by_wall_clock_timea_lagging_stream_closes_no_window_early: checks both sides of the boundary: the clock at 1 h + 40 999 ms leaves(30, 40]open and 1 h + 41 000 ms closes it.a_sample_after_a_wall_clock_close_is_latea_wall_clock_step_closes_no_window_early(follow-up commit): the system clock steps 15 min forward while the monotonic clock does not;(30, 40]stays open and nothing is counted, then closes once 1 s of monotonic time passes. Before the fix it failed with 9 windows closed by wall clock.Test-first: with
idle_closes_at/advance_idledisabled, all three fail waiting for(30, 40](ingest_shards.rswait_for_answer_at_40s); the other 10 tests in the file pass.Gates
cargo fmt --all --check,cargo clippy --workspace --all-targets --locked -D warnings: clean.cargo test --workspace(ulimit -n 65536), at the monotonic-clock commit: 252 passed, 0 failed, 3 ignored = the base's 251 tests + the 4 new ones (base test names unchanged)./metrics,/api/v1/status/asap, OTLP replies) vs the base: byte-identical except the newwindows_closed_by_wall_clockfield (0) in the status JSON and the newasap_windows_closed_by_wall_clock_totalfamily. The dump's streams do not go idle. Run on the previous chore: range step cap in the query engine, one plan test helper, QueryOutcome as Result #888 head; the rebase onto b192642 changes no code in this PR.Instantonce per flush and per coordinator tick, not per sample; parity and the bench were not rerun for it.ingest_bench 10000 600 raw 1 memory, base/new alternating, 4 rounds each: every write acknowledged in median 1.12 s / 1.13 s, every window refreshed in median 2.26 s / 2.30 s (noise; spread 2.23–2.38 s on both).windows_closed_by_wall_clock0 in every run.Open questions
L + G, has the windows in the gap closed. Samples later sent for them are dropped as late. This follows the approved rule. An alternative is to cap the idle watermark at the end of the window holdingt, which still closes the last windows but loses at most one window on a pause. Another is an off switch.Scans are counted back from the watermark, which now moves while idle. After a lookback's worth of idleness they are evicted, as a barrier would do.viewlabel. It is engine-wide, like the other window counters.