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 1sbjPV-0010dk-Sy for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Aug 2024 16:21:13 +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 1sbjPU-008MWc-8W for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Aug 2024 16:21:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sbjPT-008MWS-Ua for pgsql-hackers@lists.postgresql.org; Wed, 07 Aug 2024 16:21:11 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sbjPO-003ZIM-CH for pgsql-hackers@lists.postgresql.org; Wed, 07 Aug 2024 16:21:10 +0000 Received: from [192.168.11.6] (p3884157-ipxg13401funabasi.chiba.ocn.ne.jp [118.15.9.157]) by oss.nttdata.com (Postfix) with ESMTPSA id 24F1E619A1; Thu, 8 Aug 2024 01:21:02 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: Date: Thu, 8 Aug 2024 01:20:57 +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?J8OWbmRlciBLYWxhY8SxJw==?= , "'Shinya11.Kato@oss.nttdata.com'" , 'Kyotaro Horiguchi' , 'Shubham Khanna' References: <613adbf9-c86e-41dc-ab97-27dc4e7281c7@oss.nttdata.com> <768032ee-fb57-494b-b674-1ccb65b6f969@oss.nttdata.com> <1aa89c91-e3f1-4071-9fa9-14bffa600dd2@oss.nttdata.com> <4ab30d00-d434-4e82-af5d-260609075ff7@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/08/02 14:56, Hayato Kuroda (Fujitsu) wrote: > I moved the function to connection.c, which uses the SearchSysCache1(). > > I've tried both ways, and they worked well. One difference is that when we use > the extended ConnCacheEntry approach and the entry has been invalidated, we cannot > distinguish the reason. For example, in the below case, the entry is invalidated, > so the user_name of the output record will be NULL, whereas the user mapping is > actually still valid. We may be able to add the reason for invalidation, but > I'm not very motivated to modify the part. Understood. Also thanks for updating the patch! postgres_fdw_get_connections( IN check_conn boolean DEFAULT false, OUT server_name text, OUT valid boolean, OUT used_in_xact boolean, OUT closed boolean) returns setof record In the documentation, this part should be updated to include the user_name output column. + user_name + text + + The local user name of this connection. If the user mapping is + dropped but the connection remains open (i.e., marked as + invalid), this will be NULL. How about changing the first description to "Name of the local user mapped to the foreign server of this connection, or "public" if a public mapping is used." for more precision? - server_name | valid | used_in_xact | closed --------------+-------+--------------+-------- - loopback1 | t | t | - loopback2 | f | t | + server_name | user_name | valid | used_in_xact | closed +-------------+-----------+-------+--------------+-------- + loopback1 | postgres | t | t | + loopback2 | postgres | t | t | How about displaying the record with loopback2 and valid=false like the previous usage example? +UserMapping * +GetUserMappingByOid(Oid umid, bool missing_ok) postgres_fdw doesn't need a generic function to return UserMapping. How about simplifying the function by removing unnecessary code, e.g., as follows? ---------- tp = SearchSysCache1(USERMAPPINGOID, ObjectIdGetDatum(umid)); if (!HeapTupleIsValid(tp)) nulls[i++] = true; else { Oid userid = ((Form_pg_user_mapping) GETSTRUCT(tp))->userid; values[i++] = CStringGetTextDatum(MappingUserName(userid)); ReleaseSysCache(tp); } ---------- -ForeignTable * -GetForeignTable(Oid relid); - - - This function returns a ForeignTable object for - the foreign table with the given OID. A - ForeignTable object contains properties of the - foreign table (see foreign/foreign.h for details). - - - - Why did you remove these code? Just mistake? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION