Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUU2e-003OeI-R3 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jul 2024 16:31:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sUU1e-001CZU-Tr for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jul 2024 16:30:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUU1e-001CZL-K4 for pgsql-hackers@lists.postgresql.org; Thu, 18 Jul 2024 16:30:39 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUU1b-000EES-L0 for pgsql-hackers@lists.postgresql.org; Thu, 18 Jul 2024 16:30:38 +0000 Received: from [192.168.11.3] (p4227034-ipxg13801funabasi.chiba.ocn.ne.jp [122.26.176.34]) by oss.nttdata.com (Postfix) with ESMTPSA id 09000619B9; Fri, 19 Jul 2024 01:30:30 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: <613adbf9-c86e-41dc-ab97-27dc4e7281c7@oss.nttdata.com> Date: Fri, 19 Jul 2024 01:30:29 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Proposal] Add foreign-server health checks infrastructure To: "Hayato Kuroda (Fujitsu)" Cc: Katsuragi Yuta , vignesh C , Ted Yu , Tom Lane , "pgsql-hackers@lists.postgresql.org" , =?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= , "Shinya11.Kato@oss.nttdata.com" , Kyotaro Horiguchi , 'Shubham Khanna' References: <36981865ac13b6c40d53bf3f98667eee@oss.nttdata.com> <300fccae11de8a4ed1a2d970db1a8680@oss.nttdata.com> Content-Language: en-US From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024/07/18 19:49, Hayato Kuroda (Fujitsu) wrote: >> Shouldn't this test also check if the returned user_name is valid? > > You meant to say that we should print the user_name, right? Done. Yes, I think it's better to test if the value in the user_name column is as expected. > - I found an inconsistency of name between source and doc, > so I unified to postgres_fdw_can_verify_connection(). I'm unsure about the necessity of introducing a standalone function to check POLLRDHUP availability. Instead of providing postgres_fdw_can_verify_connection(), could we modify postgres_fdw_get_connections() to return NULL in the "closed" column on platforms where POLLRDHUP isn't supported? > - Also, test patch (0002) was combined into this. > 0002: > - user_name was added after the `valid` to preserve ordering of the old version. Do we really need to keep this ordering? Wouldn't it be more intuitive to have the user_name column next to server_name? In pg_stat_statements, for example, the ordering isn't always preserved, as seen with WAL-related columns being added in the middle. > Thanks for reviewing the patch! PSA new version. Thanks for updating the patches! The regression test for postgres_fdw failed with the following diff. ---------------------- SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; server_name | valid | user_name | used_in_xact | closed -------------+-------+-----------+--------------+-------- - loopback | f | hayato | t | + loopback | f | runner | t | | f | | t | (2 rows) ---------------------- + * If requested and the connection is not invalidated, check the + * status of the remote connection from the backend process and + * return the result. Otherwise returns NULL. + */ + if (require_verify && !entry->invalidated && entry->conn) Should we also consider checking invalidated connections? Even though a connection is marked as invalidated, it can still be used until the current transaction ends. Therefore, if an invalidated connection is used in this transaction (i.e., used_in_xact = true) and has already been closed (closed = true), users might want to consider rolling back the transaction promptly. Thought? + -- Set client_min_messages to ERROR temporary because the following + -- function only throws a WARNING on the supported platform. Is this still true? From my reading of the code, it doesn't appear that the function throws a WARNING. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION