Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions crates/plan-selection/src/search/candidates/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ pub(crate) fn validate_selected_graph(
.iter()
.map(|root| root.candidates.as_slice())
.collect();
// `to_selected_candidates` orders the roots by output index, so each
// output must be assigned exactly once before that order means anything.
let mut assigned_outputs: Vec<usize> = selected
.query_roots
.iter()
.map(|root| root.query_root)
.collect();
assigned_outputs.sort_unstable();
if !assigned_outputs
.iter()
.copied()
.eq(0..graph.query_roots.len())
{
return Err("decoded candidate selection violates dependency or root constraints".into());
}
validate_selected_connections(
graph.candidates.len(),
|candidate| {
Expand Down
6 changes: 5 additions & 1 deletion crates/plan-selection/src/search/costing/direct_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,11 @@ mod tests {
deadline: None,
refine_materialization: false,
query_roots: &originals,
realizer: &crate::search::test_realizer(&originals, &entries, &data),
realizer:
&asap_physical_asap_optimization::catalog::Stage2AssignmentRealizer {
query_time_results_retained: deployment.query_time_results_retained,
..crate::search::test_realizer(&originals, &entries, &data)
},
entries: &entries,
data: &data,
models: crate::SelectionModels {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ fn shared_pane_range_tiers_match_evaluator_for_ingestion_and_kept_refresh() {
deadline: None,
refine_materialization: false,
query_roots: &originals,
realizer: &crate::search::test_realizer(&originals, &entries, &data),
realizer: &asap_physical_asap_optimization::catalog::Stage2AssignmentRealizer {
query_time_results_retained: deployment.query_time_results_retained,
..crate::search::test_realizer(&originals, &entries, &data)
},
entries: &entries,
data: &data,
models: crate::SelectionModels {
Expand Down
27 changes: 16 additions & 11 deletions crates/planner/tests/runtime_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1889,17 +1889,27 @@ async fn a_non_negative_gauges_merged_ddsketch_panes_carry_the_relative_bound_th
}

/// Without a non-negative declaration, relative sketch error cannot propagate
/// through the average. Early candidate pruning must report that missing bound
/// and reject this no-raw deployment, just as final validation would.
/// through the average, so this no-raw deployment has no valid plan: plan
/// selection selects none. Today's engine cannot prove the catalog
/// infeasible within its budget, so it reports no plan by the deadline
/// rather than an infeasible catalog (early query pruning, which proved it,
/// is gone; #1047 P6b).
#[tokio::test]
async fn an_undeclared_gauges_merged_ddsketch_panes_get_no_relative_bound_through_avg() {
let error = plan_p99_avg(false).await.expect_err("no valid plan");
assert_plan_selection_selected_none(&error);
}

/// `error` says plan selection found no valid plan: no candidate is valid,
/// or none was validated by the deadline. Not a solver, realizer or input
/// failure.
fn assert_plan_selection_selected_none(error: &str) {
assert!(
error.contains("infeasible_under_configured_model"),
error.contains("plan selection: no valid candidate")
|| error.contains("plan selection: no plan by the deadline")
|| error.contains("the planning budget ended before a plan was selected"),
"{error}"
);
assert!(error.contains("AccuracyTargetMissed"), "{error}");
assert!(error.contains("Relative bound None"), "{error}");
}

/// `avg by (g) (quantile_over_time(0.99, x[100s]))` every 10 s at rank
Expand Down Expand Up @@ -2067,12 +2077,7 @@ async fn ignoring_accuracy_guarantees_selects_a_sketch_plan_that_runs() {
let error = plan(false)
.await
.expect_err("no candidate is valid without the setting");
assert!(
error
.to_string()
.contains("infeasible_under_configured_model"),
"{error}"
);
assert_plan_selection_selected_none(&error.to_string());
// With it.
let (installed, report) = plan(true).await.expect("a sketch plan is selected");
// A per-series KLL or DDSketch plan.
Expand Down
Loading