Try settings on sf-daqsync-02

This commit is contained in:
Dominik Werder
2023-09-14 16:55:53 +02:00
parent f869047cf5
commit b21dfae560
16 changed files with 296 additions and 159 deletions
+7 -3
View File
@@ -2,16 +2,20 @@ use crate::err::Error;
use log::*;
use netpod::Database;
use taskrun::tokio;
use tokio::task::JoinHandle;
use tokio_postgres::Client;
pub type PgClient = Client;
pub async fn make_pg_client(dbconf: &Database) -> Result<PgClient, Error> {
pub async fn make_pg_client(dbconf: &Database) -> Result<(PgClient, JoinHandle<Result<(), Error>>), Error> {
let d = dbconf;
let url = format!("postgresql://{}:{}@{}:{}/{}", d.user, d.pass, d.host, d.port, d.name);
info!("connect to {url}");
let (client, pg_conn) = tokio_postgres::connect(&url, tokio_postgres::tls::NoTls).await?;
// TODO allow clean shutdown on ctrl-c and join the pg_conn in the end:
tokio::spawn(pg_conn);
Ok(client)
let jh = tokio::spawn(async move {
pg_conn.await?;
Ok(())
});
Ok((client, jh))
}
+1 -1
View File
@@ -79,7 +79,7 @@ impl PgPool {
pub async fn new(cap: usize, dbconf: &Database) -> Result<Self, Error> {
let (tx, rx) = async_channel::bounded(2 + cap);
for _ in 0..cap {
let pgc = crate::conn::make_pg_client(dbconf).await?;
let (pgc, jh) = crate::conn::make_pg_client(dbconf).await?;
let pgc = PgClientInner { pgc, handout_count: 0 };
tx.send(pgc).await?;
}
+3 -2
View File
@@ -108,7 +108,7 @@ impl Worker {
batch_rx: Receiver<Vec<ChannelInfoQuery>>,
stats: Arc<SeriesByChannelStats>,
) -> Result<Self, Error> {
let pg = crate::conn::make_pg_client(db).await?;
let (pg, jh) = crate::conn::make_pg_client(db).await?;
let sql = concat!(
"with q1 as (select * from unnest($1::text[], $2::text[], $3::int[], $4::text[], $5::int[])",
" as inp (backend, channel, scalar_type, shape_dims, rid))",
@@ -290,7 +290,8 @@ impl Worker {
async fn work(&mut self) -> Result<(), Error> {
while let Some(batch) = self.batch_rx.next().await {
trace!("worker recv batch len {}", batch.len());
self.stats.recv_batch().inc();
self.stats.recv_items().add(batch.len() as _);
for x in &batch {
trace3!(
"search for {} {} {:?} {:?}",