Dear Önder, > As far as I can see this patch is mostly useful for detecting the failures > on the initial remote command. This is especially common when the remote > server does a failover/switchover and postgres_fdw uses a cached connection > to access to the remote server.
Sounds reasonable. Do you mean that we can add additional GUC like "postgres_fdw.initial_check", wait WL_SOCKET_CLOSED if the conneciton is found in the hash table, and do reconnection if it might be closed, right? > I think any extension that deals with multiple Postgres nodes can benefit > from such logic. In fact, the reason I realized this patch is that on the > Citus extension, we are trying to solve a similar problem [1], [2]. > Thinking even more, I think any extension that uses libpq and WaitEventSets > can benefit from such a function. OK, I agreed it may be useful, but where should this function be? This cannot be used from application, so it should not in interface/libpq dir. So backend/libpq/pqcomm.c? > I think it also depends on where you decide to put > pgfdw_connection_check_internal(). If you prefer the postgres_fdw side, > could we maybe use ConnCacheEntry in contrib/postgres_fdw/connection.c? > But if you decide to put it into the Postgres side, the API > for pgfdw_connection_check_internal() -- or equivalent function -- could be > discussed. Do we pass a WaitEventSet and if it is NULL create a new one, > else use what is passed to the function? Not sure, maybe you can come up > with a better API. Thank you for describing more detail. I can imagine you said. Best Regards, Hayato Kuroda FUJITSU LIMITED