chore(rust): gap-fill progress lines; slow-statement warning at 30 s
This commit is contained in:
1 parent
785836dcd8
commit
9b910c3cbf
5 files changed
+27
-3
No files matched your search
@@ -15,10 +15,17 @@ use sqlx::postgres::PgPoolOptions;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
|
||||
pub async fn connect(url: &str) -> Result<PgPool> {
|
||||
use sqlx::ConnectOptions;
|
||||
use std::str::FromStr;
|
||||
// sqlx warns about any statement over 1 s; the whole-history gap scan
|
||||
// legitimately takes several seconds on ~1M rows.
|
||||
let options = sqlx::postgres::PgConnectOptions::from_str(url)
|
||||
.context("invalid database URL")?
|
||||
.log_slow_statements(log::LevelFilter::Warn, std::time::Duration::from_secs(30));
|
||||
PgPoolOptions::new()
|
||||
.max_connections(4)
|
||||
.acquire_timeout(std::time::Duration::from_secs(30))
|
||||
.connect(url)
|
||||
.connect_with(options)
|
||||
.await
|
||||
.context("connecting to PostgreSQL")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user