Skip to content

Judge each analytic query's freshness against the New-Orders the terminals were told had committed - #278

Merged
tamnd merged 1 commit into
mainfrom
ch-freshness
Oct 9, 2026
Merged

tamnd merged 1 commit into
mainfrom
ch-freshness

Conversation

@tamnd

@tamnd tamnd commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Part of tamnd/rudb#1390 (W7), the HyBench freshness measure (Zhang et al., PVLDB 17, 2024) for the analytic streams.

The CH-benCHmark streams reported how long each query took but not how old its data was. W7's freshness gate reads that number: zero with visibility = committed, and at most the device card's p99 sync latency with durable (engine-v4/14-reads-stay-fast.md section 14.8, bench/tpc-c/09-ch-benchmark.md section 9.6).

With --analytic N the terminals now note each New-Order's order number and the time its commit returned, per district, in the new fresh::Acks. Before each query a stream begins a read transaction with the new Session::begin_snapshot (REPEATABLE READ READ ONLY on PostgreSQL, which takes a snapshot per statement otherwise), reads SELECT d_w_id, d_id, d_next_o_id FROM district, runs the query in the same transaction and commits. Acks::judge takes d_next_o_id - 1 as the newest order each district shows. The query is stale by the time from the oldest acknowledged order it missed to when the district read was sent, or zero. An order seen whose acknowledgement came after the read was answered counts as seen ahead, the second number of section 9.6. Orders seen more than 10 seconds before are let go.

No new flag: judging is on whenever --analytic is. The report adds ch freshness judged= late= stale_median_ms= stale_p99_ms= stale_max_ms= ahead= ahead_orders= lead_max_ms=, and ch unjudged message= if the district read fails. For example rudb-bench-kv --mode tpcc --backend rudb --target t.db --load --warehouses 2 --terminals 4 --analytic 2.

Limits: the read is sent at one instant and answered at a later one, and the snapshot falls somewhere in between, so staleness is measured from the send and lead from the answer, which errs toward zero on both. The driver does not set rudb's visibility, so a run measures whatever the database opens with, the default durable. The committed side of the gate needs that set another way.

Tests

  • fresh.rs: a snapshot is late by the oldest order it missed and ahead by the orders it saw early, including one seen before it was acknowledged at all, orders seen long ago are let go, and the district read is parsed as three numbers a row.
  • ch.rs: the ch freshness line comes once a query was judged and is left out of the reference.
  • A run on server3 against rudb: results to follow in a comment.

@tamnd tamnd added kind/feature It should do something it does not. area/tpc TPC-H and TPC-DS. labels Oct 9, 2026
@tamnd
tamnd merged commit 041b280 into main Oct 9, 2026
1 check failed
@tamnd
tamnd deleted the ch-freshness branch October 9, 2026 12:56
@tamnd tamnd mentioned this pull request Oct 12, 2026
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tpc TPC-H and TPC-DS. kind/feature It should do something it does not.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant