Skip to content

Commit

Permalink
fix: spawn a background connection thread
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePieWw committed Dec 20, 2024
1 parent 4ef9166 commit 30bab10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/meta-srv/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,15 @@ async fn create_postgres_client(opts: &MetasrvOptions) -> Result<tokio_postgres:
let postgres_url = opts.store_addrs.first().context(InvalidArgumentsSnafu {
err_msg: "empty store addrs",
})?;
let (client, _) = tokio_postgres::connect(postgres_url, NoTls)
let (client, connection) = tokio_postgres::connect(postgres_url, NoTls)
.await
.context(error::ConnectPostgresSnafu)?;

tokio::spawn(async move {
connection
.await
.context(error::PostgresExecutionSnafu)
.unwrap()
});
Ok(client)
}
2 changes: 1 addition & 1 deletion src/meta-srv/src/election/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ mod tests {
}
.fail();
}
let (client, connection) = tokio_postgres::connect(&addr, NoTls)
let (client, connection) = tokio_postgres::connect(addr, NoTls)
.await
.context(PostgresExecutionSnafu)?;
tokio::spawn(async move {
Expand Down

0 comments on commit 30bab10

Please sign in to comment.