RE: [Proposal] Add foreign-server health checks infrastructure
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Katsuragi Yuta' <katsuragiy@oss.nttdata.com>
Cc: 'Ted Yu' <yuzhihong@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, vignesh C <vignesh21@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, Önder Kalacı <onderkalaci@gmail.com>, Fujii Masao <masao.fujii@oss.nttdata.com>, "Shinya11.Kato@oss.nttdata.com" <Shinya11.Kato@oss.nttdata.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Date: 2023-02-09T14:39:34Z
Lists: pgsql-hackers
Attachments
- v31-0001-Add-PQconnCheck-and-PQcanConnCheck-to-libpq.patch (application/octet-stream) patch v31-0001
- v31-0002-postgres_fdw-add-postgres_fdw_verify_connection_.patch (application/octet-stream) patch v31-0002
- v31-0003-add-test.patch (application/octet-stream) patch v31-0003
- v31-0004-add-kqueue-support-for-PQconnCheck-and-PQcanConn.patch (application/octet-stream) patch v31-0004
Dear Katsuragi-san, Thank you for reviewing! PSA new version patches. > 0001: > + while (result < 0 && errno == EINTR); > + > + if (result < 0) > + return -1; > > this `return -1` is not indented properly. This part is no longer needed. Please see another discussion[1]. > 0002: > + <term><function>postgres_fdw_verify_connection_states(server_name > text) returns boolean</function></term> > ... > + extension to the <symbol>poll</symbol> system call, including > Linux. This > + returns <literal>true</literal> if checked connections are still > valid, > + or the checking is not supported on this platform. > <literal>false</literal> > + is returned if the local session seems to be disconnected from > other > + servers. Example usage of the function: > > Here, 'still valid' seems a little bit confusing because this 'valid' is > not > the same as postgres_fdw_get_connections's 'valid' [1]. > > Should 'still valid' be 'existing connection is not closed by the remote > peer'? > But this description does not cover all the cases where this function > returns true... > I think one choice is to write all the cases like 'returns true if any > of the > following condition is satisfied. 1) existing connection is not closed > by the > remote peer 2) there is no connection for specified server yet 3) the > checking > is not supported...'. If my understanding is not correct, please point > it out. Modified like you pointed out. > BTW, is it reasonable to return true if ConnectionHash is not > initialized or > there is no ConnCacheEntry for specified remote server? What do you > think > about returning NULL in that case? I'm not sure which one is better, but modified accordingly. > 0003: > I think it is better that the test covers all the new functions. > How about adding a test for postgres_fdw_verify_connection_states_all? > > > +-- > =================================================== > ================ > +-- test for postgres_fdw_verify_foreign_servers function > +-- > =================================================== > ================ > > Writing all the functions' name like 'test for > postgres_fdw_verify_connection_states > and postgres_fdw_can_verify_connection_states' looks straightforward. > What do you think about this? Added. > 0004: > Sorry, I have not read 0004. I will read. No problem:-). [1]: https://www.postgresql.org/message-id/TYAPR01MB58664E039F45959AB321FA1FF5D99%40TYAPR01MB5866.jpnprd01.prod.outlook.com Best Regards, Hayato Kuroda FUJITSU LIMITED
Commits
-
postgres_fdw: Extend postgres_fdw_get_connections to return user name.
- 4f08ab554577 18.0 landed
-
postgres_fdw: Fix bug in connection status check.
- 454aab4b738e 18.0 landed
-
postgres_fdw: Add connection status check to postgres_fdw_get_connections().
- 857df3cef7be 18.0 landed
-
postgres_fdw: Add "used_in_xact" column to postgres_fdw_get_connections().
- c297a47c5f8d 18.0 landed
-
doc: Enhance documentation for postgres_fdw_get_connections() output columns.
- 284c030a10b8 18.0 landed
-
Avoid reference to nonexistent array element in ExecInitAgg().
- 92957ed98c5c 16.0 cited
-
Add WL_SOCKET_CLOSED for socket shutdown events.
- 50e570a59e7f 15.0 cited
-
postgres_fdw: reestablish new connection if cached one is detected as broken.
- 32a9c0bdf493 14.0 cited