From fe186bda78c4a0ccbb691489c744e6317f648434 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Mon, 3 Mar 2025 08:51:30 +0900 Subject: postgres_fdw: Extend postgres_fdw_get_connections to return remote backend PID. This commit adds a new "remote_backend_pid" output column to the postgres_fdw_get_connections function. It returns the process ID of the remote backend, on the foreign server, handling the connection. This enhancement is useful for troubleshooting, monitoring, and reporting. For example, if a connection is unexpectedly closed by the foreign server, the remote backend's PID can help diagnose the cause. No extension version bump is needed, as commit c297a47c5f already handled it for v18~. Author: Sagar Dilip Shedge Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/CAPhYifF25q5xUQWXETfKwhc0YVa_6+tfG9Kw4bCvCjpCWxYs2A@mail.gmail.com --- doc/src/sgml/postgres-fdw.sgml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'doc/src/sgml/postgres-fdw.sgml') diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgml index d2998c13d5d..a7f2f5ca182 100644 --- a/doc/src/sgml/postgres-fdw.sgml +++ b/doc/src/sgml/postgres-fdw.sgml @@ -854,7 +854,7 @@ OPTIONS (ADD password_required 'false'); postgres_fdw_get_connections( IN check_conn boolean DEFAULT false, OUT server_name text, OUT user_name text, OUT valid boolean, OUT used_in_xact boolean, - OUT closed boolean) + OUT closed boolean, OUT remote_backend_pid int4) returns setof record @@ -882,11 +882,11 @@ OPTIONS (ADD password_required 'false'); Example usage of the function: postgres=# SELECT * FROM postgres_fdw_get_connections(true); - server_name | user_name | valid | used_in_xact | closed --------------+-----------+-------+--------------+-------- - loopback1 | postgres | t | t | f - loopback2 | public | t | t | f - loopback3 | | f | t | f + server_name | user_name | valid | used_in_xact | closed | remote_backend_pid +-------------+-----------+-------+--------------+----------------------------- + loopback1 | postgres | t | t | f | 1353340 + loopback2 | public | t | t | f | 1353120 + loopback3 | | f | t | f | 1353156 The output columns are described in . @@ -951,6 +951,17 @@ postgres=# SELECT * FROM postgres_fdw_get_connections(true); is not available on this platform. + + remote_backend_pid + int4 + + Process ID of the remote backend, on the foreign server, + handling the connection. If the remote backend is terminated and + the connection is closed (with closed set to + true), this still shows the process ID of + the terminated backend. + + -- cgit v1.2.3