mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-23 06:09:59 +00:00
Remove unnecessary dependencies to synchronous 'postgres' crate (#10938)
The synchronous 'postgres' crate is just a wrapper around the async 'tokio_postgres' crate. Some places were unnecessarily using the re-exported NoTls and Error from the synchronous 'postgres' crate, even though they were otherwise using the 'tokio_postgres' crate. Tidy up by using the tokio_postgres types directly.
This commit is contained in:
committed by
GitHub
parent
df264380b9
commit
a6f315c9c9
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -4172,7 +4172,6 @@ dependencies = [
|
|||||||
"pageserver_client",
|
"pageserver_client",
|
||||||
"pageserver_compaction",
|
"pageserver_compaction",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"postgres",
|
|
||||||
"postgres-protocol",
|
"postgres-protocol",
|
||||||
"postgres-types",
|
"postgres-types",
|
||||||
"postgres_backend",
|
"postgres_backend",
|
||||||
@@ -4259,7 +4258,6 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"http-utils",
|
"http-utils",
|
||||||
"pageserver_api",
|
"pageserver_api",
|
||||||
"postgres",
|
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
@@ -4674,7 +4672,6 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"itertools 0.10.5",
|
"itertools 0.10.5",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"postgres",
|
|
||||||
"tokio-postgres",
|
"tokio-postgres",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
@@ -5816,7 +5813,6 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"pageserver_api",
|
"pageserver_api",
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"postgres",
|
|
||||||
"postgres-protocol",
|
"postgres-protocol",
|
||||||
"postgres_backend",
|
"postgres_backend",
|
||||||
"postgres_ffi",
|
"postgres_ffi",
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ license.workspace = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
postgres.workspace = true
|
|
||||||
tokio-postgres.workspace = true
|
tokio-postgres.workspace = true
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
|
|
||||||
|
|||||||
@@ -171,10 +171,10 @@ impl PgConnectionConfig {
|
|||||||
tokio_postgres::Client,
|
tokio_postgres::Client,
|
||||||
tokio_postgres::Connection<tokio_postgres::Socket, tokio_postgres::tls::NoTlsStream>,
|
tokio_postgres::Connection<tokio_postgres::Socket, tokio_postgres::tls::NoTlsStream>,
|
||||||
),
|
),
|
||||||
postgres::Error,
|
tokio_postgres::Error,
|
||||||
> {
|
> {
|
||||||
self.to_tokio_postgres_config()
|
self.to_tokio_postgres_config()
|
||||||
.connect(postgres::NoTls)
|
.connect(tokio_postgres::NoTls)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ num_cpus.workspace = true
|
|||||||
num-traits.workspace = true
|
num-traits.workspace = true
|
||||||
once_cell.workspace = true
|
once_cell.workspace = true
|
||||||
pin-project-lite.workspace = true
|
pin-project-lite.workspace = true
|
||||||
postgres.workspace = true
|
|
||||||
postgres_backend.workspace = true
|
postgres_backend.workspace = true
|
||||||
postgres-protocol.workspace = true
|
postgres-protocol.workspace = true
|
||||||
postgres-types.workspace = true
|
postgres-types.workspace = true
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ tokio.workspace = true
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
tokio-util.workspace = true
|
tokio-util.workspace = true
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
postgres.workspace = true
|
|
||||||
bytes.workspace = true
|
bytes.workspace = true
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ pub struct BasebackupRequest {
|
|||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub async fn new(connstring: String) -> anyhow::Result<Self> {
|
pub async fn new(connstring: String) -> anyhow::Result<Self> {
|
||||||
let (client, connection) = tokio_postgres::connect(&connstring, postgres::NoTls).await?;
|
let (client, connection) =
|
||||||
|
tokio_postgres::connect(&connstring, tokio_postgres::NoTls).await?;
|
||||||
|
|
||||||
let conn_task_cancel = CancellationToken::new();
|
let conn_task_cancel = CancellationToken::new();
|
||||||
let conn_task = tokio::spawn({
|
let conn_task = tokio::spawn({
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ use bytes::BytesMut;
|
|||||||
use chrono::{NaiveDateTime, Utc};
|
use chrono::{NaiveDateTime, Utc};
|
||||||
use fail::fail_point;
|
use fail::fail_point;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use postgres::{error::SqlState, SimpleQueryMessage, SimpleQueryRow};
|
|
||||||
use postgres_ffi::WAL_SEGMENT_SIZE;
|
use postgres_ffi::WAL_SEGMENT_SIZE;
|
||||||
use postgres_ffi::{v14::xlog_utils::normalize_lsn, waldecoder::WalDecodeError};
|
use postgres_ffi::{v14::xlog_utils::normalize_lsn, waldecoder::WalDecodeError};
|
||||||
use postgres_protocol::message::backend::ReplicationMessage;
|
use postgres_protocol::message::backend::ReplicationMessage;
|
||||||
use postgres_types::PgLsn;
|
use postgres_types::PgLsn;
|
||||||
use tokio::{select, sync::watch, time};
|
use tokio::{select, sync::watch, time};
|
||||||
|
use tokio_postgres::{error::SqlState, SimpleQueryMessage, SimpleQueryRow};
|
||||||
use tokio_postgres::{replication::ReplicationStream, Client};
|
use tokio_postgres::{replication::ReplicationStream, Client};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tracing::{debug, error, info, trace, warn, Instrument};
|
use tracing::{debug, error, info, trace, warn, Instrument};
|
||||||
@@ -64,7 +64,7 @@ pub(super) struct WalConnectionStatus {
|
|||||||
|
|
||||||
pub(super) enum WalReceiverError {
|
pub(super) enum WalReceiverError {
|
||||||
/// An error of a type that does not indicate an issue, e.g. a connection closing
|
/// An error of a type that does not indicate an issue, e.g. a connection closing
|
||||||
ExpectedSafekeeperError(postgres::Error),
|
ExpectedSafekeeperError(tokio_postgres::Error),
|
||||||
/// An "error" message that carries a SUCCESSFUL_COMPLETION status code. Carries
|
/// An "error" message that carries a SUCCESSFUL_COMPLETION status code. Carries
|
||||||
/// the message part of the original postgres error
|
/// the message part of the original postgres error
|
||||||
SuccessfulCompletion(String),
|
SuccessfulCompletion(String),
|
||||||
@@ -143,7 +143,7 @@ pub(super) async fn handle_walreceiver_connection(
|
|||||||
let mut config = wal_source_connconf.to_tokio_postgres_config();
|
let mut config = wal_source_connconf.to_tokio_postgres_config();
|
||||||
config.application_name(format!("pageserver-{}", timeline.conf.id.0).as_str());
|
config.application_name(format!("pageserver-{}", timeline.conf.id.0).as_str());
|
||||||
config.replication_mode(tokio_postgres::config::ReplicationMode::Physical);
|
config.replication_mode(tokio_postgres::config::ReplicationMode::Physical);
|
||||||
match time::timeout(connect_timeout, config.connect(postgres::NoTls)).await {
|
match time::timeout(connect_timeout, config.connect(tokio_postgres::NoTls)).await {
|
||||||
Ok(client_and_conn) => client_and_conn?,
|
Ok(client_and_conn) => client_and_conn?,
|
||||||
Err(_elapsed) => {
|
Err(_elapsed) => {
|
||||||
// Timing out to connect to a safekeeper node could happen long time, due to
|
// Timing out to connect to a safekeeper node could happen long time, due to
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ futures.workspace = true
|
|||||||
once_cell.workspace = true
|
once_cell.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
pageserver_api.workspace = true
|
pageserver_api.workspace = true
|
||||||
postgres.workspace = true
|
|
||||||
postgres-protocol.workspace = true
|
postgres-protocol.workspace = true
|
||||||
pprof.workspace = true
|
pprof.workspace = true
|
||||||
rand.workspace = true
|
rand.workspace = true
|
||||||
|
|||||||
@@ -343,8 +343,11 @@ async fn recovery_stream(
|
|||||||
cfg.replication_mode(tokio_postgres::config::ReplicationMode::Physical);
|
cfg.replication_mode(tokio_postgres::config::ReplicationMode::Physical);
|
||||||
|
|
||||||
let connect_timeout = Duration::from_millis(10000);
|
let connect_timeout = Duration::from_millis(10000);
|
||||||
let (client, connection) = match time::timeout(connect_timeout, cfg.connect(postgres::NoTls))
|
let (client, connection) = match time::timeout(
|
||||||
.await
|
connect_timeout,
|
||||||
|
cfg.connect(tokio_postgres::NoTls),
|
||||||
|
)
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
Ok(client_and_conn) => client_and_conn?,
|
Ok(client_and_conn) => client_and_conn?,
|
||||||
Err(_elapsed) => {
|
Err(_elapsed) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user