Repository navigation
Conversation
…neage frame (failing first) Tests for decisions 30, 31 and 34 of the design doc (section 8), with stubs for the new interfaces: - common: the lineage frame's pinned bytes for sequences 0, 1, 300 and u64::MAX (the collector's encoder holds the same vectors) and each refusal with its reason. - otlp: a state's sequence and kind come from the frame in sketch.envelope, the record's bytes are those behind it, and a bare ASAPv1 state, frame version 2, or a self-contradicting frame refuses the request. - storage: incomplete marks are indexed after a restart (stored windows or not, whatever revision is read later, not past retention); a version 5 segment reads with no marks. - precompute: records before their base wait for it and apply in order (closed and open windows, a new epoch's delta before its full); a base still missing past the reorder wait marks the window incomplete, not before; the reorder wait is the file's close delay. - data plane: a gap is held, then incomplete after the close delay; records out of order in separate requests answer as in-order ones; an incomplete window stays incomplete after a restart over the view files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…neage frame Decisions 30, 31 and 34 of the design doc (section 8): - Reorder buffer (31): a delta whose base has not been applied (a later sequence, or a new epoch's delta before its full) is held per lineage and sequence, and applied as soon as its base is, with the records held after it. A record held for the collector's declared close delay (CollectorViewOptions::reorder_wait_ms, the file's window_close_delay_ms; 6 s by default) with its base still missing marks its window incomplete (Staging::expire_held, every ingest pass); the window's other held records are dropped. New outcome "held". - Persisted incomplete marks (30): Precompute::mark_incomplete returns the marks, the committer queues them to the persist thread (PersistPool::queue_incomplete), which appends a marks-only record (RecordHead::incomplete) per retention; ViewFiles::index collects them within retention and startup re-marks the store. FORMAT_VERSION 5 -> 6 so a version 5 data plane sets the new segments aside rather than cutting them at the first new head; version 5 segments still read. - Lineage frame (34): the otlp adapter reads the record's sequence and kind from the frame in front of its ASAPv1 bytes in sketch.envelope (common::unframe_lineage) instead of three point attributes; a bare ASAPv1 state, another frame version or a self-contradicting frame refuses the request. The attribute constants are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…failing first) The reorder wait is to be the declared window close delay plus the same 2 s clock-skew allowance as the idle close: the file's 3 s delay gives a 5 s wait, the default 8 s. In the data plane, a held record is not yet incomplete at the declared delay alone (6 s), only at 8 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
A held record's window is marked incomplete after the declared window close delay plus the same 2 s clock-skew allowance as the idle close (CollectorViewOptions::reorder_wait_ms: the file's delay + 2 s, default 8 s), for consistency with how long a stopped collector's windows wait. 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
window_close_delay_msplus the 2 s skew allowance (the same wait as the idle close). Incomplete marks are written to the view files (FORMAT_VERSION5 → 6). The lineage is read from the binary frame insketch.envelope(A1 | flags | uleb128 sequence | uleb128 base | ASAPv1), which ASAPCollector-public#64 emits.Review guide
feat/collector-state-lineage(Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay #893,9492be29). Stack: feat(precompute): close an idle stream's last windows by wall-clock time #889 → feat(precompute): merge late samples into committed windows within retention #892 → Collector view states: ingest OTLP states of the views a collector builds, staged and committed as the view's windows #890 → Collector views: control plane rule and collector-views file, data plane --collector-views #891 → Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay #893 → this PR. A separate PR keeps Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay #893 reviewable as it stands.03406863adds the tests, which fail first against stubs, and0fe4d8f0is the implementation. Then5c189c78(test, failing first) →60127a2eadd the skew allowance to the reorder wait.crates/precompute/src/collector.rs:Staging::stage/Staging::apply(Applies::Aheadand theheldmap) andStaging::expire_held.crates/storage/src/{segment,persist,persist_pool}.rs:RecordHead::incomplete,ViewFiles::mark_incomplete/take_incomplete, the version 5 read path, andPersistJob::Incomplete.crates/common/src/view_states.rs:unframe_lineage.crates/adapters/ingest/otlp/src/lib.rs: the frame replaces the three attributes.engine.rswiring (expire every pass, queue the marks to the persist pool, restore the marks at startup), the README, and the test helpers.Behavior: before → after
The workload is
quantile_over_time(0.99, data[5m])(a DDSketch chain on the collector). The collector's window(T−5 s, T]for jobaarrives as: full (seq 0); then, in separate requests, delta 2, delta 1, and a restarted instance's delta (epoch 2, seq 1) before its full.records_out_of_order_answer_as_in_order_ones)window_close_delay_ms+ 2 s (default 8 s), countedheldthenincompletean_incomplete_window_stays_incomplete_after_a_restart)asap.sequence,asap.state_kind,asap.base_sequenceattributesA1 00 00(full),A1 01 02 01(delta 2); a bare ASAPv1 state is refused (400)This serves correctness for collector views: no plausible-but-wrong answers across a reordered export or a restart.
Interfaces
crates/common/src/view_states.rsThe three attribute constants are removed because the frame replaces the attributes.
crates/precompute/src/collector.rspub struct CollectorViewOptions { pub plan_id: Option<String>, pub views: BTreeSet<PhysicalASAPNodeId>, pub idle_close_ms: u64, + /// How long an early record waits for its base (monotonic ms): the file's + /// window_close_delay_ms + 2000 skew allowance, as idle_close_ms; default 8000. + pub reorder_wait_ms: u64, } pub struct CollectorStateIngestReport { pub staged: u64, pub duplicate: u64, pub merged: u64, pub late_merged: u64, pub late_dropped: u64, + /// Held for their base (applied when it comes, or incomplete after the wait). + pub held: u64, /// Records of a window already incomplete. pub incomplete: u64, pub rejected: BTreeMap<&'static str, u64>, } pub mod outcome { + pub const HELD: &str = "held"; }crates/storage/src/{segment,persist,persist_pool}.rsUsage (as
records_out_of_order_answer_as_in_order_onesandan_incomplete_window_stays_incomplete_after_a_restartrun it):Algorithm changes
Receiver: reorder buffer
apply_to→ Merged / Duplicate / Broken; Broken marked the window at once.apply_to→ Merged / Duplicate / Ahead (a delta past its lineage's next sequence, or of an epoch with no full yet).held[(group, end, series, epoch)][sequence]; a repeat of a held sequence is a duplicate.sequence + 1is applied next, and so on.expire_held(now)runs on every ingest pass. When a held record is older thanreorder_wait_ms, its window is marked incomplete (if still kept; otherwise it is countedlate_dropped) and all records held for that window are dropped.records_before_their_base_wait_for_it,a_base_missing_past_the_reorder_wait_marks_its_window_incomplete, and the data-plane tests below.View files: incomplete marks
ViewStore.Precompute::mark_incompletereturns(group, range, views), and the committer queues it to the persist thread, which appends a marks-only record (RecordHead::incomplete) to each retention's active segment.indexcollects the marks within each view's retention of its newest window (all marks if the view has no window), and startup re-marks the store.Decisions and open questions
sketch.envelope; no sketchlib change.60127a2e, test-first after5c189c78.Verification
Remote runner (an eval host), with an rsynced copy and its own target dir. Formatting was checked locally.
cargo fmt --checkcargo clippy -p common -p otlp -p storage -p precompute -p data_plane --all-targets -- -D warningscommonlibotlplineage_frames_are_decoded_and_checkedreplaces the attribute teststoragelibincomplete_marks_are_indexed_after_a_restart,a_version_5_segment_reads_with_no_marks;an_older_format_version_segment_is_set_asidenow uses version 4precomputelibrecords_before_their_base_wait_for_it,a_base_missing_past_the_reorder_wait_marks_its_window_incompletedata_plane --test collector_viewsrecords_out_of_order_answer_as_in_order_ones,an_incomplete_window_stays_incomplete_after_a_restart; on a manual clock:a_gap_leaves_the_window_unanswered,a_restarted_collector_resynchronizes_with_a_full(held, then incomplete after the wait)data_plane --test view_persistence --test view_tiering5c189c78(test) →60127a2ethe_idle_close_is_the_files_close_delay_plus_skewanda_gap_leaves_the_window_unanswered; then precompute lib 16 and collector_views 20 passed, clippy cleana_gap_leaves_the_window_unanswerednow checks that the window is not yet incomplete at the declared 6 s, only at 8 s03406863New tests:
records_before_their_base_wait_for_it: deltas 3, 2 and a new epoch's delta are held and applied in order once deltas 1 and the full arrive; a repeated held record is a duplicate; an open window with its delta before its full.a_base_missing_past_the_reorder_wait_marks_its_window_incomplete: nothing is marked before the wait; at the wait the window is marked once and its held records are dropped; a base arriving later is not applied; other windows are untouched.incomplete_marks_are_indexed_after_a_restart: stored and unstored windows; a later revision of the window; a mark past retention is dropped; marks are taken once.records_out_of_order_answer_as_in_order_ones/an_incomplete_window_stays_incomplete_after_a_restart: end to end over HTTP, including a restart over the view files.Bytes per state (collector side, ASAPCollector-public#64, same input): no lineage 215.9 B, attributes 264.6 B, frame 219.7 B.
Follow-ups
🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf