Support escape sequence for cluster_name in postgres_fdw.application_name

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-01-25 07:02:39
Message-ID: 1041dc9a-c976-049f-9f14-e7d94c29c4b2@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Commit 6e0cb3dec1 allowed postgres_fdw.application_name to include escape sequences %a (application name), %d (database name), %u (user name) and %p (pid). In addition to them, I'd like to support the escape sequence (e.g., %C) for cluster name there. This escape sequence is helpful to investigate where each remote transactions came from. Thought?

Patch attached.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
pgfdw_appname_cluster_name_v1.patch text/plain 1.6 KB

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: masao(dot)fujii(at)oss(dot)nttdata(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-01-27 08:10:42
Message-ID: 20220127.171042.1194024926941192601.horikyota.ntt@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

At Tue, 25 Jan 2022 16:02:39 +0900, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote in
> Hi,
>
> Commit 6e0cb3dec1 allowed postgres_fdw.application_name to include
> escape sequences %a (application name), %d (database name), %u (user
> name) and %p (pid). In addition to them, I'd like to support the
> escape sequence (e.g., %C) for cluster name there. This escape
> sequence is helpful to investigate where each remote transactions came
> from. Thought?
>
> Patch attached.

I don't object to adding more meaningful replacements, but more escape
sequence makes me anxious about the increased easiness of exceeding
the size limit of application_name. Considering that it is used to
identify fdw-initinator server, we might need to add padding (or
rather truncating) option in the escape sequence syntax, then warn
about truncated application_names for safety.

Is the reason for 'C' in upper-case to avoid possible conflict with
'c' of log_line_prefix? I'm not sure that preventive measure is worth
doing. Looking the escape-sequence spec alone, it seems to me rather
strange that an upper-case letter is used in spite of its lower-case
is not used yet.

Otherwise all looks fine to me except the lack of documentation.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center


From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-01-27 10:26:39
Message-ID: b4cb3b76-903f-50fe-7dc2-b37d851e7b56@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2022/01/27 17:10, Kyotaro Horiguchi wrote:
> At Tue, 25 Jan 2022 16:02:39 +0900, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote in
>> Hi,
>>
>> Commit 6e0cb3dec1 allowed postgres_fdw.application_name to include
>> escape sequences %a (application name), %d (database name), %u (user
>> name) and %p (pid). In addition to them, I'd like to support the
>> escape sequence (e.g., %C) for cluster name there. This escape
>> sequence is helpful to investigate where each remote transactions came
>> from. Thought?
>>
>> Patch attached.
>
> I don't object to adding more meaningful replacements, but more escape
> sequence makes me anxious about the increased easiness of exceeding
> the size limit of application_name.

If this is really an issue, it might be time to reconsider the size limit of application_name. If it's considered too short, the patch that enlarges it should be proposed separately.

> Considering that it is used to
> identify fdw-initinator server, we might need to add padding (or
> rather truncating) option in the escape sequence syntax, then warn
> about truncated application_names for safety.

I failed to understand this. Could you tell me why we might need to add padding option here?

> Is the reason for 'C' in upper-case to avoid possible conflict with
> 'c' of log_line_prefix?

Yes.

> I'm not sure that preventive measure is worth
> doing. Looking the escape-sequence spec alone, it seems to me rather
> strange that an upper-case letter is used in spite of its lower-case
> is not used yet.

I have no strong opinion about using %C. If there is better character for the escape sequence, I'm happy to use it. So what character is more proper? %c?

> Otherwise all looks fine to me except the lack of documentation.

The patch updated postgres-fdw.sgml, but you imply there are other documents that the patch should update? Could you tell me where the patch should update?

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION


From: "r(dot)takahashi_2(at)fujitsu(dot)com" <r(dot)takahashi_2(at)fujitsu(dot)com>
To: 'Fujii Masao' <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-01-28 05:07:28
Message-ID: OS0PR01MB5682DB788FD7EAD3BDBC36F182229@OS0PR01MB5682.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Thank you for developing this feature.
I think adding escape sequence for cluster_name is useful too.

> Is the reason for 'C' in upper-case to avoid possible conflict with
> 'c' of log_line_prefix? I'm not sure that preventive measure is worth
> doing. Looking the escape-sequence spec alone, it seems to me rather
> strange that an upper-case letter is used in spite of its lower-case
> is not used yet.

I think %c of log_line_prefix (Session ID) is also useful for postgres_fdw.application_name.
Therefore, how about adding both %c (Session ID) and %C (cluster_name)?

Regards,
Ryohei Takahashi


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-01-28 14:10:01
Message-ID: CA+TgmobqH83_iGmpUgjHrZa9ANPKaC9FD_5NMghrMBWUnwF17A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Jan 27, 2022 at 3:10 AM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
> Is the reason for 'C' in upper-case to avoid possible conflict with
> 'c' of log_line_prefix? I'm not sure that preventive measure is worth
> doing. Looking the escape-sequence spec alone, it seems to me rather
> strange that an upper-case letter is used in spite of its lower-case
> is not used yet.

It's good to be consistent, though.

--
Robert Haas
EDB: http://www.enterprisedb.com


From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: "r(dot)takahashi_2(at)fujitsu(dot)com" <r(dot)takahashi_2(at)fujitsu(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-02-07 14:03:56
Message-ID: 87a9be5a-ff59-47ff-ac7f-fad7891a46e3@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2022/01/28 14:07, r(dot)takahashi_2(at)fujitsu(dot)com wrote:
> I think %c of log_line_prefix (Session ID) is also useful for postgres_fdw.application_name.
> Therefore, how about adding both %c (Session ID) and %C (cluster_name)?

+1

Attached is the updated version of the patch. It adds those escape sequences %c and %C.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
pgfdw_appname_cluster_name_v2.patch text/plain 1.9 KB

From: "r(dot)takahashi_2(at)fujitsu(dot)com" <r(dot)takahashi_2(at)fujitsu(dot)com>
To: 'Fujii Masao' <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-02-09 00:19:03
Message-ID: OS3PR01MB56888811167D27D24BE429C0822E9@OS3PR01MB5688.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Thank you for updating the patch.
I agree with the documentation and program.

How about adding the test for %c (Session ID)?
(Adding the test for %C (cluster_name) seems difficult.)

Regards,
Ryohei Takahashi


From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: masao(dot)fujii(at)oss(dot)nttdata(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-02-09 07:55:49
Message-ID: 20220209.165549.93763781529472908.horikyota.ntt@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Sorry for missing this.

At Thu, 27 Jan 2022 19:26:39 +0900, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote in
>
> On 2022/01/27 17:10, Kyotaro Horiguchi wrote:
> > I don't object to adding more meaningful replacements, but more escape
> > sequence makes me anxious about the increased easiness of exceeding
> > the size limit of application_name.
>
> If this is really an issue, it might be time to reconsider the size
> limit of application_name. If it's considered too short, the patch
> that enlarges it should be proposed separately.

That makes sense.

> > Considering that it is used to
> > identify fdw-initinator server, we might need to add padding (or
> > rather truncating) option in the escape sequence syntax, then warn
> > about truncated application_names for safety.
>
> I failed to understand this. Could you tell me why we might need to
> add padding option here?

My point was "truncating" option, which limits the length of the
replacement string. But expanding the application_name limit is more
sensible.

> > Is the reason for 'C' in upper-case to avoid possible conflict with
> > 'c' of log_line_prefix?
>
> Yes.
>
> > I'm not sure that preventive measure is worth
> > doing. Looking the escape-sequence spec alone, it seems to me rather
> > strange that an upper-case letter is used in spite of its lower-case
> > is not used yet.
>
> I have no strong opinion about using %C. If there is better character
> for the escape sequence, I'm happy to use it. So what character is
> more proper? %c?

I think so.

> > Otherwise all looks fine to me except the lack of documentation.
>
> The patch updated postgres-fdw.sgml, but you imply there are other
> documents that the patch should update? Could you tell me where the
> patch should update?

Mmm. I should have missed that part.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center


From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: "r(dot)takahashi_2(at)fujitsu(dot)com" <r(dot)takahashi_2(at)fujitsu(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-02-10 14:42:11
Message-ID: 0fbc8eb3-f5b9-33ed-9cf2-dceef9a3658f@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2022/02/09 9:19, r(dot)takahashi_2(at)fujitsu(dot)com wrote:
> Hi,
>
>
> Thank you for updating the patch.
> I agree with the documentation and program.
>
> How about adding the test for %c (Session ID)?
> (Adding the test for %C (cluster_name) seems difficult.)

Ok, I added the tests for %c and %C escape sequences.
Attached is the updated version of the patch.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
pgfdw_appname_cluster_name_v3.patch text/plain 4.0 KB

From: "r(dot)takahashi_2(at)fujitsu(dot)com" <r(dot)takahashi_2(at)fujitsu(dot)com>
To: 'Fujii Masao' <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-02-14 23:52:58
Message-ID: TYCPR01MB569309233FBCE8936E9202B882339@TYCPR01MB5693.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi Fujii san,

Thank you for updating the patch.
I have no additional comments.

Regards,
Ryohei Takahashi


From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: "r(dot)takahashi_2(at)fujitsu(dot)com" <r(dot)takahashi_2(at)fujitsu(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: 2022-02-18 02:40:44
Message-ID: 1af49aae-5516-603b-908d-8578ebb8d4e5@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2022/02/15 8:52, r(dot)takahashi_2(at)fujitsu(dot)com wrote:
> Hi Fujii san,
>
>
> Thank you for updating the patch.
> I have no additional comments.

Thanks for the review! Pushed.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION