From 557516d5bf109b56c77ad48554e67b36f20d5d83 Mon Sep 17 00:00:00 2001 From: zzylol Date: Sun, 6 Dec 2026 05:31:31 +0000 Subject: [PATCH] test(data_plane): failing test for a raw read split over a shard's chunks Test-first phase 3 of the parallel query-time execution plan (D1): a raw read whose chunks are converted on the worker pool returns the sequential read's batches cell for cell and in order, and its rows in the time range, for a metric and a keyed table, key and field predicates, with and without the read cache and with a series partition. RawData::read_with(.., p) is a stub that reads on the calling thread, so the chunk-task assertion fails. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01K1M6bpWvKMxYBvtAgpDYGp --- data_plane/src/store.rs | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/data_plane/src/store.rs b/data_plane/src/store.rs index 10e0addc..de19a0c9 100644 --- a/data_plane/src/store.rs +++ b/data_plane/src/store.rs @@ -660,6 +660,20 @@ impl RawData { request: &RawDataRequest, reads: Option<&RawReads>, partition: Option<&PartitionReads>, + ) -> Result { + self.read_with(metric, request, reads, partition, 1) + } + + /// [`Self::read`] with its chunks converted on up to `parallelism` + /// worker-pool threads: the same batches in the same order (spec + /// `parallel-query-exec`, I6). STUB: reads on the calling thread. + pub(crate) fn read_with( + &self, + metric: &str, + request: &RawDataRequest, + reads: Option<&RawReads>, + partition: Option<&PartitionReads>, + _parallelism: usize, ) -> Result { let columns = column_kinds(metric, request)?; let Some(metric_data) = self.by_metric.get(metric) else { @@ -743,6 +757,7 @@ impl RawData { Ok(RawRead { batches, rows_in_time_range, + chunk_tasks: 0, }) } } @@ -840,6 +855,9 @@ impl SeriesVerdicts { pub(crate) struct RawRead { pub batches: Vec, pub rows_in_time_range: u64, + /// Chunks the read converted on the worker pool (0: read on the + /// calling thread). + pub chunk_tasks: usize, } /// Rows of the raw reads of some runs (the query runs: `/metrics`): @@ -2991,6 +3009,86 @@ mod tests { } } + /// D1 (spec `parallel-query-exec`, I6): a read whose chunks are + /// converted on the worker pool returns the sequential read's batches, + /// cell for cell and in order, and its rows in the time range: a metric + /// and a keyed table, with key and field predicates, with and without + /// the read cache, and with a series partition; at parallelism 4 the + /// chunks ran as pool tasks. + #[test] + fn a_chunk_parallel_read_equals_the_sequential_read() { + let schema = schema(); + let all: Vec = samples().into_iter().flatten().collect(); + let mut metric = RawData::for_metrics(&["m_store_test".to_string()], 5_000); + metric.append(&all); + metric.seal_through(20_000); + let requests = table_rows(); + let mut keyed = table_data(&requests.iter().map(|r| keyed_layout(r)).collect::>()); + keyed.seal_through(20_000); + let table = table_schema(); + let field_and_key = [text_is(1, &["a"]), text_is(2, &["i1", "i4"])]; + let field = [text_is(2, &["i5", "i2"])]; + let cases: Vec<( + &RawData, + &str, + &Arc, + &[ScalarExpr<()>], + Option<(i64, i64)>, + )> = vec![ + (&metric, "m_store_test", &schema, &[], None), + ( + &metric, + "m_store_test", + &schema, + &[], + Some((12_000, 27_000)), + ), + (&keyed, TABLE, &table, &[], None), + (&keyed, TABLE, &table, &field_and_key, None), + (&keyed, TABLE, &table, &field, Some((2_100, 27_001))), + ]; + let partition = PartitionReads::new(SeriesPartition { index: 1, count: 3 }); + for (raw, name, schema, predicates, range) in cases { + let request = RawDataRequest { + time_range_ms: range, + schema, + predicates, + }; + for (shared, part) in [(false, None), (true, None), (false, Some(&partition))] { + let cache = RawReads::default(); + let reads = shared.then_some(&cache); + let sequential = raw.read_with(name, &request, reads, part, 1).unwrap(); + assert_eq!(sequential.chunk_tasks, 0); + let cache = RawReads::default(); + let reads = shared.then_some(&cache); + let parallel = raw.read_with(name, &request, reads, part, 4).unwrap(); + let label = format!( + "{name} {range:?} {} predicates, shared {shared}, partition {}", + predicates.len(), + part.is_some() + ); + assert_eq!( + parallel.rows_in_time_range, sequential.rows_in_time_range, + "{label}" + ); + assert_eq!(parallel.batches.len(), sequential.batches.len(), "{label}"); + for (a, b) in parallel.batches.iter().zip(&sequential.batches) { + assert_eq!( + format!("{:?}", a.to_rows()), + format!("{:?}", b.to_rows()), + "{label}" + ); + } + if sequential.batches.len() > 1 { + assert!( + parallel.chunk_tasks > 0, + "{label}: chunks not read on the pool" + ); + } + } + } + } + /// Eviction drops the panes ending at or before the cutoff, keeps the /// pane the cutoff falls in, and no read returns a sample at or /// before the cutoff: a read of a range starting before it fails (its