mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-27 02:10:38 +00:00
feat: init PgElection with candidate registration (#5209)
* feat: init PgElection fix: release advisory lock fix: handle duplicate keys chore: update comments fix: unlock if acquired the lock chore: add TODO and avoid unwrap refactor: check both lock and expire time, add more comments chore: fmt fix: deal with multiple edge cases feat: init PgElection with candidate registration chore: fmt chore: remove * test: add unit test for pg candidate registration * test: add unit test for pg candidate registration * chore: update pg env * chore: make ci happy * fix: spawn a background connection thread * chore: typo * fix: shadow the election client for now * fix: fix ci * chore: readability * chore: follow review comments * refactor: use kvbackend for pg election * chore: rename * chore: make clippy happy * refactor: use pg server time instead of local ones * chore: typo * chore: rename infancy to leader_infancy for clarification * chore: clean up * chore: follow review comments * chore: follow review comments * ci: unit test should test all features * ci: fix * ci: just test pg
This commit is contained in:
@@ -16,6 +16,7 @@ use std::any::Any;
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
|
||||
use common_telemetry::error;
|
||||
use snafu::ResultExt;
|
||||
use tokio_postgres::types::ToSql;
|
||||
use tokio_postgres::{Client, NoTls};
|
||||
@@ -97,7 +98,11 @@ impl PgStore {
|
||||
let (client, conn) = tokio_postgres::connect(url, NoTls)
|
||||
.await
|
||||
.context(ConnectPostgresSnafu)?;
|
||||
tokio::spawn(async move { conn.await.context(ConnectPostgresSnafu) });
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = conn.await {
|
||||
error!(e; "connection error");
|
||||
}
|
||||
});
|
||||
Self::with_pg_client(client).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user