Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnzIM-0001PG-Th for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Nov 2021 08:30:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mnzIL-0002AI-Hx for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Nov 2021 08:30:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnzIL-0002A8-8D for pgsql-hackers@lists.postgresql.org; Fri, 19 Nov 2021 08:30:53 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnzII-00076I-As for pgsql-hackers@lists.postgresql.org; Fri, 19 Nov 2021 08:30:52 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id 14D0A609D1; Fri, 19 Nov 2021 17:30:47 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.4 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 19 Nov 2021 17:30:47 +0900 From: Shinya Kato To: kuroda.hayato@fujitsu.com Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [Proposal] Add foreign-server health checks infrastructure In-Reply-To: References: <54449d7bea79263e937266ad6ebc65b3@oss.nttdata.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <4e64bb8a0a88f5b6ac5a8901377c81af@oss.nttdata.com> X-Sender: Shinya11.Kato@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-11-18 21:43, kuroda.hayato@fujitsu.com wrote: > Dear Kato-san, > > Thank you for your interest! > >> > I also want you to review the postgres_fdw part, >> > but I think it should not be attached because cfbot cannot understand >> > such a dependency >> > and will throw build error. Do you know how to deal with them in this >> > case? >> >> I don't know how to deal with them, but I hope you will attach the >> PoC, >> as it may be easier to review. > > OK, I attached the PoC along with the dependent patches. Please see > the zip file. > add_helth_check_... patch is written by me, and other two patches are > just copied from [1]. > In the new callback function ConnectionHash is searched sequentially > and > WaitEventSetWait() is performed for WL_SOCKET_CLOSED socket event. > This event is added by the dependent ones. Thank you for sending the patches! I confirmed that they can be compiled and tested successfully on CentOS 8. I haven't looked at the core of the code yet, but I took a quick look at it. + { + {"remote_servers_connection_check_interval", PGC_USERSET, CONN_AUTH_SETTINGS, + gettext_noop("Sets the time interval between checks for disconnection of remote servers."), + NULL, + GUC_UNIT_MS + }, + &remote_servers_connection_check_interval, + 0, 0, INT_MAX, + }, If you don't use check_hook, assign_hook and show_hook, you should explicitly write "NULL, NULL, NULL", as show below. + { + {"remote_servers_connection_check_interval", PGC_USERSET, CONN_AUTH_SETTINGS, + gettext_noop("Sets the time interval between checks for disconnection of remote servers."), + NULL, + GUC_UNIT_MS + }, + &remote_servers_connection_check_interval, + 0, 0, INT_MAX, + NULL, NULL, NULL + }, + ereport(ERROR, + errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("Postgres foreign server %s might be down.", + server->servername)); According to [1], error messages should start with a lowercase letter and not use a period. Also, along with the rest of the code, it is a good idea to enclose the server name in double quotes. I'll get back to you once I've read all the code. [1] https://www.postgresql.org/docs/devel/error-style-guide.html -- Regards, -- Shinya Kato Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION