From fa354a65ab51b424bec52ea604894f13682b05e5 Mon Sep 17 00:00:00 2001 From: Vlad Lazar Date: Fri, 27 Sep 2024 12:36:43 +0100 Subject: [PATCH] libs: improve logging on PG connection errors (#9130) ## Problem We get some unexpected errors, but don't know who they're happening for. ## Summary of change Add tenant id and peer address to PG connection error logs. Related https://github.com/neondatabase/cloud/issues/17336 --- pageserver/src/page_service.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pageserver/src/page_service.rs b/pageserver/src/page_service.rs index 9261b7481d..98d718dde4 100644 --- a/pageserver/src/page_service.rs +++ b/pageserver/src/page_service.rs @@ -273,10 +273,20 @@ async fn page_service_conn_main( info!("Postgres client disconnected ({io_error})"); Ok(()) } else { - Err(io_error).context("Postgres connection error") + let tenant_id = conn_handler.timeline_handles.tenant_id(); + Err(io_error).context(format!( + "Postgres connection error for tenant_id={:?} client at peer_addr={}", + tenant_id, peer_addr + )) } } - other => other.context("Postgres query error"), + other => { + let tenant_id = conn_handler.timeline_handles.tenant_id(); + other.context(format!( + "Postgres query error for tenant_id={:?} client peer_addr={}", + tenant_id, peer_addr + )) + } } } @@ -340,6 +350,10 @@ impl TimelineHandles { } }) } + + fn tenant_id(&self) -> Option { + self.wrapper.tenant_id.get().copied() + } } pub(crate) struct TenantManagerWrapper {