From 8aa3dce8cfbe548685e83939e01839352fd34388 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 6 Feb 2024 19:18:14 -0500 Subject: [PATCH] Better bounds debugging (#1180) Add debug logging for bounds -- seems like this has been a big point of contention / slow startups --- martin/src/pg/query_tables.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/martin/src/pg/query_tables.rs b/martin/src/pg/query_tables.rs index d67455b4..23a13c15 100644 --- a/martin/src/pg/query_tables.rs +++ b/martin/src/pg/query_tables.rs @@ -115,23 +115,35 @@ pub async fn table_to_query( if info.bounds.is_none() { match bounds_type { BoundsCalcType::Skip => {} - BoundsCalcType::Quick | BoundsCalcType::Calc => { + BoundsCalcType::Calc => { + debug!("Computing {} table bounds for {id}", info.format_id()); + info.bounds = calc_bounds(&pool, &schema, &table, &geometry_column, srid).await?; + } + BoundsCalcType::Quick => { + debug!( + "Computing {} table bounds with {}s timeout for {id}", + info.format_id(), + DEFAULT_BOUNDS_TIMEOUT.as_secs() + ); let bounds = calc_bounds(&pool, &schema, &table, &geometry_column, srid); - if bounds_type == BoundsCalcType::Calc { - info.bounds = bounds.await?; + pin_mut!(bounds); + if let Ok(bounds) = timeout(DEFAULT_BOUNDS_TIMEOUT, &mut bounds).await { + info.bounds = bounds?; } else { - pin_mut!(bounds); - if let Ok(bounds) = timeout(DEFAULT_BOUNDS_TIMEOUT, &mut bounds).await { - info.bounds = bounds?; - } else { - warn!( + warn!( "Timeout computing {} bounds for {id}, aborting query. Use --auto-bounds=calc to wait until complete, or check the table for missing indices.", info.format_id(), ); - } } } } + + if let Some(bounds) = info.bounds { + debug!( + "The computed bounds for {id} from {} are {bounds}", + info.format_id() + ); + } } let properties = if let Some(props) = &info.properties {