Skip to content

Commit

Permalink
Log a warning if PG startup takes too long
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsier committed Oct 7, 2023
1 parent afc9ef2 commit aa9ce8b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion martin/src/pg/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use futures::future::try_join;
use futures::pin_mut;
use log::warn;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use tilejson::TileJSON;
use tokio::time::timeout;

use crate::config::{copy_unrecognized_config, UnrecognizedValues};
use crate::pg::config_function::FuncInfoSources;
Expand Down Expand Up @@ -110,8 +114,18 @@ impl PgConfig {

pub async fn resolve(&mut self, id_resolver: IdResolver) -> crate::Result<Sources> {
let pg = PgBuilder::new(self, id_resolver).await?;

let instantiate_tables = pg.instantiate_tables();
pin_mut!(instantiate_tables);
if timeout(Duration::from_secs(5), &mut instantiate_tables)
.await
.is_err()
{
warn!("PostgreSQL table discovery is taking too long. Make sure your table geo columns have a GIS index, or use --disabling-bounds.");
}

let ((mut tables, tbl_info), (funcs, func_info)) =
try_join(pg.instantiate_tables(), pg.instantiate_functions()).await?;
try_join(instantiate_tables, pg.instantiate_functions()).await?;

self.tables = Some(tbl_info);
self.functions = Some(func_info);
Expand Down

0 comments on commit aa9ce8b

Please sign in to comment.