Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions rust/cubestore/cubestore/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2812,21 +2812,34 @@ mod tests {

println!("All partitions: {:#?}", partitions);

let plans = service
.plan_query("SELECT sum(num) from foo.numbers where num = 50")
.await
.unwrap();
// Semi-busy-wait for, or, seemingly, induce, compaction for 2000 ms.
let num_attempts = 100;
for i in 0..num_attempts {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's better to use JobResultListener and wait_for_job_results here or metastore listener.

cC @waralexrom @waralex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me what job to wait for. Based on logs, some sort of PartitionCompaction job. But I don't know the right way to see which ones I want to wait on.

tokio::time::sleep(Duration::from_millis(20)).await;

let plans = service
.plan_query("SELECT sum(num) from foo.numbers where num = 50")
.await
.unwrap();

let worker_plan = pp_phys_plan(plans.worker.as_ref());
let parquet_regex = Regex::new(r"\d+-[a-z0-9]+\.parquet").unwrap();
let matches = parquet_regex.captures_iter(&worker_plan).count();
let chunk_parquet_regex = Regex::new(r"\d+-[a-z0-9]+\.chunk\.parquet").unwrap();
let chunk_matches = chunk_parquet_regex.captures_iter(&worker_plan).count();

let worker_plan = pp_phys_plan(plans.worker.as_ref());
println!("Worker Plan: {}", worker_plan);
let parquet_regex = Regex::new(r"\d+-[a-z0-9]+.parquet").unwrap();
let matches = parquet_regex.captures_iter(&worker_plan).count();
assert!(
// TODO 2 because partition pruning doesn't respect half open intervals yet
matches < 3 && matches > 0,
"{}\nshould have 2 and less partition scan nodes",
worker_plan
);
if matches < 3 && matches > 0 && chunk_matches == 0 {
break;
} else if i == num_attempts - 1 {
panic!(
"{}\nshould have 2 and less partition scan nodes, matches = {}, chunk_matches = {}",
worker_plan,
matches,
chunk_matches,
);
}
}
})
.await;
}
Expand Down
Loading