Re: Walsender doesn't process options passed in the startup packet

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Walsender doesn't process options passed in the startup packet
Date: 2010-09-10 10:17:36
Message-ID: AANLkTikd_1UyOaie9q3fyVcmqz1oQg7qKEWJRPwDXcXk@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I found walsender didn't process options (e.g., application_name
in primary_conninfo) passed in the startup packet. The cause is
that walsender doesn't execute process_postgres_switches() and
SetConfigOption() in InitPostgres().

The attached patch fixes this bug.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
startup_packet_options_and_walsender_v1.patch application/octet-stream 5.8 KB

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Walsender doesn't process options passed in the startup packet
Date: 2010-09-10 10:54:54
Message-ID: 4C8A0E7E.3090801@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 10/09/10 13:17, Fujii Masao wrote:
> Hi,
>
> I found walsender didn't process options (e.g., application_name
> in primary_conninfo) passed in the startup packet. The cause is
> that walsender doesn't execute process_postgres_switches() and
> SetConfigOption() in InitPostgres().
>
> The attached patch fixes this bug.

Hmm, should walsender call InitializeClientEncoding too? It affects
error messages. And what about per-user settings in pg_db_role_setting?

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Walsender doesn't process options passed in the startup packet
Date: 2010-09-10 12:56:25
Message-ID: AANLkTikFJj3GZKr8vYPGjzQXeL6_Os2JLBUH_yjYbnOt@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Sep 10, 2010 at 7:54 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>> I found walsender didn't process options (e.g., application_name
>> in primary_conninfo) passed in the startup packet. The cause is
>> that walsender doesn't execute process_postgres_switches() and
>> SetConfigOption() in InitPostgres().
>>
>> The attached patch fixes this bug.
>
> Hmm, should walsender call InitializeClientEncoding too? It affects error
> messages. And what about per-user settings in pg_db_role_setting?

Yes, we should do both. SetDatabasePath() and RelationCacheInitializePhase3()
need to be called before accessing to pg_db_role_setting. And we should apply
PostAuthDelay. I attached the updated patch.

BTW, this issue seems to derive from the following commit.
http://archives.postgresql.org/pgsql-committers/2010-04/msg00175.php

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
startup_packet_options_and_walsender_v2.patch application/octet-stream 6.6 KB

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Walsender doesn't process options passed in the startup packet
Date: 2010-09-13 03:14:53
Message-ID: AANLkTikCd0LwmGO9xaUctzqembV7AX6WN=GvkyHC1++s@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Sep 10, 2010 at 9:56 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> BTW, this issue seems to derive from the following commit.
> http://archives.postgresql.org/pgsql-committers/2010-04/msg00175.php

> it was previously using an untenable assumption that template1 would
> always be available to connect to

The above commit message shows that the updated patch is untenable too
since it assumes the existence of the template1.

Is there way to access to pg_db_role_setting without connecting to the
specific database? If not, it's difficult for walsender to process the
per-user settings since it's tied to no database.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Walsender doesn't process options passed in the startup packet
Date: 2010-09-13 03:32:26
Message-ID: 20853.1284348746@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> On Fri, Sep 10, 2010 at 9:56 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> BTW, this issue seems to derive from the following commit.
>> http://archives.postgresql.org/pgsql-committers/2010-04/msg00175.php

>> it was previously using an untenable assumption that template1 would
>> always be available to connect to

> The above commit message shows that the updated patch is untenable too
> since it assumes the existence of the template1.

> Is there way to access to pg_db_role_setting without connecting to the
> specific database? If not, it's difficult for walsender to process the
> per-user settings since it's tied to no database.

Huh? walsender has no business applying any per-user or per-database
settings.

regards, tom lane


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Walsender doesn't process options passed in the startup packet
Date: 2010-09-13 05:10:22
Message-ID: AANLkTim1CnwOcBccRAu52GSrK7XvewGq=PmD1SWyZJ8Z@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 13, 2010 at 12:32 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Huh?  walsender has no business applying any per-user or per-database
> settings.

Okay. I got rid of the access to pg_db_role_setting from the patch.
I attached the updated version, which makes walsender process the
options passed in the startup packet, apply PostAuthDelay and initialize
client encoding.

OTOH, I can believe that some people would create a dedicated role for
replication and configure the parameters for replication on the role.
What about leaving the capability to apply per-role settings as a TODO
item?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
startup_packet_options_and_walsender_v3.patch application/octet-stream 6.1 KB

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Walsender doesn't process options passed in the startup packet
Date: 2010-09-13 06:03:32
Message-ID: 4C8DBEB4.7020801@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 13/09/10 08:10, Fujii Masao wrote:
> On Mon, Sep 13, 2010 at 12:32 PM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Huh? walsender has no business applying any per-user or per-database
>> settings.
>
> Okay. I got rid of the access to pg_db_role_setting from the patch.
> I attached the updated version, which makes walsender process the
> options passed in the startup packet, apply PostAuthDelay and initialize
> client encoding.
>
> OTOH, I can believe that some people would create a dedicated role for
> replication and configure the parameters for replication on the role.

Right, per-database settings clearly make no sense, but per-role
settings do. There isn't very many settings that make sense for
walsender, but client_encoding is one example. I agree it's not terribly
useful, but would be nice for the sake of completeness.

> What about leaving the capability to apply per-role settings as a TODO
> item?

Yeah, seems best at this point.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Walsender doesn't process options passed in the startup packet
Date: 2010-09-13 09:02:31
Message-ID: 4C8DE8A7.7060101@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 13/09/10 08:10, Fujii Masao wrote:
> Okay. I got rid of the access to pg_db_role_setting from the patch.
> I attached the updated version, which makes walsender process the
> options passed in the startup packet, apply PostAuthDelay and initialize
> client encoding.

Thanks, committed.

I moved the check for "MyProcPort == NULL" case to the callers of
process_startup_packet(), it seems more logical to me.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com