Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(proxy): remove postgres notice logs #10254

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions libs/proxy/tokio-postgres2/src/connect.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::client::SocketConfig;
use crate::codec::BackendMessage;
use crate::config::Host;
use crate::connect_raw::connect_raw;
use crate::connect_socket::connect_socket;
use crate::tls::{MakeTlsConnect, TlsConnect};
use crate::{Client, Config, Connection, Error, RawConnection};
use postgres_protocol2::message::backend::Message;
use tokio::net::TcpStream;
use tokio::sync::mpsc;

Expand Down Expand Up @@ -43,7 +41,7 @@ where
let RawConnection {
stream,
parameters,
delayed_notice,
delayed_notice: _,
process_id,
secret_key,
} = connect_raw(socket, tls, config).await?;
Expand All @@ -63,13 +61,7 @@ where
secret_key,
);

// delayed notices are always sent as "Async" messages.
let delayed = delayed_notice
.into_iter()
.map(|m| BackendMessage::Async(Message::NoticeResponse(m)))
.collect();

let connection = Connection::new(stream, delayed, parameters, receiver);
let connection = Connection::new(stream, parameters, receiver);

Ok((client, connection))
}
23 changes: 8 additions & 15 deletions libs/proxy/tokio-postgres2/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::codec::{BackendMessage, BackendMessages, FrontendMessage, PostgresCodec};
use crate::error::DbError;
use crate::maybe_tls_stream::MaybeTlsStream;
use crate::{AsyncMessage, Error, Notification};
use bytes::BytesMut;
use fallible_iterator::FallibleIterator;
use futures_util::{ready, Sink, Stream};
use log::{info, trace};
use log::trace;
use postgres_protocol2::message::backend::Message;
use postgres_protocol2::message::frontend;
use std::collections::{HashMap, VecDeque};
Expand Down Expand Up @@ -55,7 +54,7 @@ pub struct Connection<S, T> {
/// HACK: we need this in the Neon Proxy to forward params.
pub parameters: HashMap<String, String>,
receiver: mpsc::UnboundedReceiver<Request>,
pending_responses: VecDeque<BackendMessage>,
pending_responses: Option<BackendMessage>,
responses: VecDeque<Response>,
state: State,
}
Expand All @@ -67,15 +66,14 @@ where
{
pub(crate) fn new(
stream: Framed<MaybeTlsStream<S, T>, PostgresCodec>,
pending_responses: VecDeque<BackendMessage>,
parameters: HashMap<String, String>,
receiver: mpsc::UnboundedReceiver<Request>,
) -> Connection<S, T> {
Connection {
stream,
parameters,
receiver,
pending_responses,
pending_responses: None,
responses: VecDeque::new(),
state: State::Active,
}
Expand All @@ -85,7 +83,7 @@ where
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<BackendMessage, Error>>> {
if let Some(message) = self.pending_responses.pop_front() {
if let Some(message) = self.pending_responses.take() {
trace!("retrying pending response");
return Poll::Ready(Some(Ok(message)));
}
Expand All @@ -109,9 +107,8 @@ where
};

let (mut messages, request_complete) = match message {
BackendMessage::Async(Message::NoticeResponse(body)) => {
let error = DbError::parse(&mut body.fields()).map_err(Error::parse)?;
return Poll::Ready(Ok(AsyncMessage::Notice(error)));
BackendMessage::Async(Message::NoticeResponse(_)) => {
continue;
}
BackendMessage::Async(Message::NotificationResponse(body)) => {
let notification = Notification {
Expand Down Expand Up @@ -160,7 +157,7 @@ where
}
Poll::Pending => {
self.responses.push_front(response);
self.pending_responses.push_back(BackendMessage::Normal {
self.pending_responses = Some(BackendMessage::Normal {
messages,
request_complete,
});
Expand Down Expand Up @@ -328,11 +325,7 @@ where
type Output = Result<(), Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
while let Some(message) = ready!(self.poll_message(cx)?) {
if let AsyncMessage::Notice(notice) = message {
info!("{}: {}", notice.severity(), notice.message());
}
}
while ready!(self.poll_message(cx)?).is_some() {}
Poll::Ready(Ok(()))
}
}
5 changes: 0 additions & 5 deletions libs/proxy/tokio-postgres2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub use crate::client::{Client, SocketConfig};
pub use crate::config::Config;
pub use crate::connect_raw::RawConnection;
pub use crate::connection::Connection;
use crate::error::DbError;
pub use crate::error::Error;
pub use crate::generic_client::GenericClient;
pub use crate::query::RowStream;
Expand Down Expand Up @@ -100,10 +99,6 @@ impl Notification {
#[derive(Debug, Clone)]
#[non_exhaustive]
pub enum AsyncMessage {
/// A notice.
///
/// Notices use the same format as errors, but aren't "errors" per-se.
Notice(DbError),
/// A notification.
///
/// Connections can subscribe to notifications with the `LISTEN` command.
Expand Down
3 changes: 0 additions & 3 deletions proxy/src/serverless/conn_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ pub(crate) fn poll_client<C: ClientInnerExt>(
let message = ready!(connection.poll_message(cx));

match message {
Some(Ok(AsyncMessage::Notice(notice))) => {
info!(%session_id, "notice: {}", notice);
}
Some(Ok(AsyncMessage::Notification(notif))) => {
warn!(%session_id, pid = notif.process_id(), channel = notif.channel(), "notification received");
}
Expand Down
3 changes: 0 additions & 3 deletions proxy/src/serverless/local_conn_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ pub(crate) fn poll_client<C: ClientInnerExt>(
let message = ready!(connection.poll_message(cx));

match message {
Some(Ok(AsyncMessage::Notice(notice))) => {
info!(%session_id, "notice: {}", notice);
}
Some(Ok(AsyncMessage::Notification(notif))) => {
warn!(%session_id, pid = notif.process_id(), channel = notif.channel(), "notification received");
}
Expand Down
Loading