Skip to content

Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay - #893

Draft
zzylol wants to merge 2 commits into
feat/collector-views-filefrom
feat/collector-state-lineage
Draft

zzylol wants to merge 2 commits into
feat/collector-views-filefrom
feat/collector-state-lineage

Conversation

@zzylol

@zzylol zzylol commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Review first

Wire (ASAPCollector-public emits these)

Tier Field Type
Schema (metric metadata) asap.producer_epoch decimal text of a u64
Record (point attribute) asap.sequence int; 0 for a full
Record asap.state_kind "full" | "delta"
Record asap.base_sequence int, deltas only; must be sequence − 1

A missing/inconsistent lineage attribute or epoch refuses the request (400, OtlpError::ViewIdentity), as a missing sketch.envelope does. None of them becomes a label.

Interfaces

 // crates/common
 pub struct CollectorViewStates {
     pub plan_id: String,
     pub node_id: PhysicalASAPNodeId,
     pub key: ViewStateKey,
+    pub producer_epoch: u64,
     pub series: Vec<CollectorSeriesStates>,
 }
 pub struct ViewStateRecord {
     pub window_start_ms: i64,
     pub window_end_ms: i64,
     pub asapv1: Vec<u8>,
     pub sample_count: u64,
+    pub sequence: u64,
+    pub kind: StateKind,
 }
+pub enum StateKind { Full, Delta { base_sequence: u64 } }
 pub struct CollectorViewsFile {
     ...
     pub backend_reads_raw: BTreeMap<String, bool>,
+    pub window_close_delay_ms: u64,
     pub outputs: Vec<PhysicalASAPNodeId>,
     ...
 }
 pub mod view_identity {
+    pub const PRODUCER_EPOCH: &str = "asap.producer_epoch";
+    pub const SEQUENCE: &str = "asap.sequence";
+    pub const STATE_KIND: &str = "asap.state_kind";
+    pub const BASE_SEQUENCE: &str = "asap.base_sequence";
 }

 // crates/precompute
 pub struct CollectorStateIngestReport {
     ...
     pub late_dropped: u64,
+    pub incomplete: u64,
     ...
 }
+pub const CLOCK_SKEW_ALLOWANCE_MS: u64 = 2_000;
-impl From<&CollectorViewsFile> for CollectorViewOptions  // idle_close_ms = 8_000
+impl From<&CollectorViewsFile> for CollectorViewOptions  // idle_close_ms = window_close_delay_ms + 2_000

 // crates/storage
+impl ViewStore { pub fn mark_incomplete(&mut self, view: PhysicalASAPNodeId, end_ms: i64) }

Decisions (see the design doc §8)

  • DDSketch delta = the DDSketch of the samples since the base (exactly its bucket-count increments); KLL delta = a KLL of the new samples, merged (fully mergeable, within the rank-error bound). One apply rule (kernel merge) for both; no new codec.
  • Resynchronization: a full at every window and at every collector restart (new epoch). No backend→collector signal: the processor never sees the exporter's reply. A broken lineage is not repaired; its window is forwarded until it leaves retention.

Tests (run: affected only, on a remote runner; fmt + clippy -D warnings on otlp, common, storage, precompute, control_plane, data_plane)

  • otlp: 51 passed, incl. lineage_attributes_are_decoded_and_checked and a missing epoch in a_bad_view_identity_refuses_the_request.
  • precompute collector unit: corrections_with_equal_bytes_both_merge, a_broken_lineage_marks_its_window_incomplete, the_idle_close_is_the_files_close_delay_plus_skew, updated windows_close_through_the_newest_staged_and_later_states_merge — pass.
  • storage: a_range_holding_an_incomplete_window_is_not_read — pass.
  • control_plane::collector_views: 8 passed (file round-trips window_close_delay_ms).
  • data_plane::collector_views: 18 passed, new: corrections_with_equal_bytes_both_merge, open_window_deltas_answer_and_end_at_the_close_answer, a_gap_leaves_the_window_unanswered, a_restarted_collector_resynchronizes_with_a_full, windows_of_a_stopped_collector_close_after_the_declared_delay.

Open questions

None. Both earlier questions were answered on 2026-11-30 (design doc decisions 30–34) and are implemented in the draft PR #897, stacked on this one:

  • Incomplete marks persist in the view files (FORMAT_VERSION 5 → 6; version 5 segments are still read).
  • A receiver reorder buffer holds a delta that arrives before its base. The window becomes incomplete only when the declared window_close_delay_ms passes with the base still missing.
  • The lineage moves from these attributes into a binary frame in sketch.envelope (ASAPCollector-public#64). Delivery is at-least-once with no resync request. A KLL delta is a partial sketch, recorded as a departure from the reference protocol.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf

@zzylol zzylol added enhancement New feature or request area: control plane Planning, configuration, routing, and control-plane orchestration area: data plane Runtime ingestion, storage, and query-serving data paths labels Nov 30, 2026
@zzylol
zzylol force-pushed the feat/collector-views-file branch 2 times, most recently from f6a3f5f to 40d0d0d Compare November 30, 2026 07:30
zzylol and others added 2 commits November 30, 2026 07:31
…eclared close delay (failing first)

Tests for sequence numbers and delta transmission
(docs/design/collector-sketch-ingest.md, section 8): the OTLP adapter
decodes and checks each state's producer epoch, sequence, kind and base;
two corrections with equal bytes both merge; open-window deltas answer
and end at the at-close answer; a delta after a gap leaves its window
unanswered; a restarted collector's full starts a new lineage and its
delta without a full is never applied; the collector-views file carries
the collector's window_close_delay_ms, which closes a stopped collector's
windows. The existing tests' states carry a lineage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…he declared delay

Each collector state is a record of its (view, series, window) lineage:
the producer epoch is metric metadata (asap.producer_epoch), the
sequence, kind and base are point attributes (asap.sequence,
asap.state_kind, asap.base_sequence), decoded by the OTLP adapter into
CollectorViewStates::producer_epoch and ViewStateRecord::{sequence, kind}.

Staging replaces the envelope-hash set with per-series lineages
(epoch, last applied sequence): a full of a new epoch or a delta onto its
lineage's last record merges; an applied (epoch, sequence) is a
duplicate, so two corrections with equal bytes are two records; a delta
after a gap, with no lineage, or of a new epoch without its full is never
applied and marks its window incomplete. The committer marks the window,
and the windows of the groups reading it, in the view store
(ViewStore::mark_incomplete); a read of a range holding a marked window
fails as a missing window does (NotReady), and cached results reading it
are stale. Later records of an incomplete window are dropped and counted
(outcome incomplete). Marks go with retention.

The control plane copies the capabilities' window_close_delay_ms into the
collector-views file; CollectorViewOptions::from(file) closes idle
windows after it plus a 2 s skew allowance instead of a fixed 8 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: control plane Planning, configuration, routing, and control-plane orchestration area: data plane Runtime ingestion, storage, and query-serving data paths enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant