Re: [Proposal] Add foreign-server health checks infrastructure

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: Katsuragi Yuta <katsuragiy(at)oss(dot)nttdata(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Ted Yu <yuzhihong(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Önder Kalacı <onderkalaci(at)gmail(dot)com>, "Shinya11(dot)Kato(at)oss(dot)nttdata(dot)com" <Shinya11(dot)Kato(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, 'Shubham Khanna' <khannashubham1197(at)gmail(dot)com>
Subject: Re: [Proposal] Add foreign-server health checks infrastructure
Date: 2024-07-18 16:30:29
Message-ID: 613adbf9-c86e-41dc-ab97-27dc4e7281c7@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amonson, Paul D 2024-07-18 16:33:22 RE: Proposal for Updating CRC32C with AVX-512 Algorithm.
Previous Message Robert Haas 2024-07-18 16:27:27 Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal