From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
To: Alexey Kondratov <a.kondratov@postgrespro.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
Date: Fri, 4 Dec 2020 15:19:23 +0900
Message-ID: <2d5cb0b3-a6e8-9bbb-953f-879f47128faa@oss.nttdata.com> (raw)
In-Reply-To: <CALj2ACXBgRBxGvyPA=kWF=96h9rdTAcUqBGbkRgwOx_-vyN3+g@mail.gmail.com>
References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com>
<CALj2ACVKQeXJ2okDDDiSC5y6i1tfd3P+n7-5iwqnQ=JiOxUyMA@mail.gmail.com>
<160467818521.7362.11186359886835925531.pgcf@coridan.postgresql.org>
<6df6525ca7a4b54a4a39f55e4dd6b3e9@postgrespro.ru>
<CALj2ACVODykNQQAuz3Veh5S9J3QfAi4D9CsExguMhYB4-+-YGw@mail.gmail.com>
<f58d1df4ae58f6cf3bfa560f923462e0@postgrespro.ru>
<CALj2ACX4B9sBTKPg70TzKfPfPJ=ndocU6hY5jii5wDvzW2X2DQ@mail.gmail.com>
<c22ad9fcdba6ab768ec2ea86d33d0c18@postgrespro.ru>
<CALj2ACW+PzzuqE6YOueNUi5Zek9XTv9P3FXdT4XF3-1JDk4RuA@mail.gmail.com>
<CALj2ACU0gf_Xf2sAtrCRhvLc-G42UqLGthDfVC9G1jzUpBcQ1w@mail.gmail.com>
<1f29ad3f1d8b969dfde6d500bbd9d82d@postgrespro.ru>
<CALj2ACVq99r+s04tWrD8TBG6QOfa=r1j0JXvKbO6JFmrMgdWpg@mail.gmail.com>
<be224d0520df0594b0693c95bd19fe0a@postgrespro.ru>
<CALj2ACXBgRBxGvyPA=kWF=96h9rdTAcUqBGbkRgwOx_-vyN3+g@mail.gmail.com>
On 2020/11/27 11:12, Bharath Rupireddy wrote:
> On Wed, Nov 25, 2020 at 12:13 AM Alexey Kondratov
> <a.kondratov@postgrespro.ru> wrote:
>>
>> 1) Return 'true' if there were open connections and we successfully
>> closed them.
>> 2) Return 'false' in the no-op case, i.e. there were no open
>> connections.
>> 3) Rise an error if something went wrong. And non-existing server case
>> belongs to this last category, IMO.
>>
>
> Done this way.
>
>>
>> I am not sure, but I think, that instead of adding this additional flag
>> into ConnCacheEntry structure we can look on entry->xact_depth and use
>> local:
>>
>> bool used_in_current_xact = entry->xact_depth > 0;
>>
>> for exactly the same purpose. Since we set entry->xact_depth to zero at
>> the end of xact, then it was used if it is not zero. It is set to 1 by
>> begin_remote_xact() called by GetConnection(), so everything seems to be
>> fine.
>>
>
> Done.
>
>>
>> In the case of pgfdw_inval_callback() this argument makes sense, since
>> syscache callbacks work that way, but here I can hardly imagine a case
>> where we can use it. Thus, it still looks as a preliminary complication
>> for me, since we do not have plans to use it, do we? Anyway, everything
>> seems to be working fine, so it is up to you to keep this additional
>> argument.
>>
>
> Removed the cacheid variable.
>
>>
>> Following this logic:
>>
>> 1) If keep_connections == true, then per-server keep_connection has a
>> *higher* priority, so one can disable caching of a single foreign
>> server.
>>
>> 2) But if keep_connections == false, then it works like a global switch
>> off indifferently of per-server keep_connection's, i.e. they have a
>> *lower* priority.
>>
>> It looks fine for me, at least I cannot propose anything better, but
>> maybe it should be documented in 0004?
>>
>
> Done.
>
>>
>> I think that GUC acronym is used widely only in the source code and
>> Postgres docs tend to do not use it at all, except from acronyms list
>> and a couple of 'GUC parameters' collocation usage. And it never used in
>> a singular form there, so I think that it should be rather:
>>
>> A configuration parameter,
>> <varname>postgres_fdw.keep_connections</varname>, default being...
>>
>
> Done.
>
>>
>> The whole paragraph is really difficult to follow. It could be something
>> like that:
>>
>> <para>
>> Note that setting <varname>postgres_fdw.keep_connections</varname>
>> to
>> off does not discard any previously made and still open
>> connections immediately.
>> They will be closed only at the end of a future transaction, which
>> operated on them.
>>
>> To close all connections immediately use
>> <function>postgres_fdw_disconnect</function> function.
>> </para>
>>
>
> Done.
>
> Attaching the v2 patch set. Please review it further.
Regarding the 0001 patch, we should add the function that returns
the information of cached connections like dblink_get_connections(),
together with 0001 patch? Otherwise it's not easy for users to
see how many cached connections are and determine whether to
disconnect them or not. Sorry if this was already discussed before.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: masao.fujii@oss.nttdata.com, bharath.rupireddyforpostgres@gmail.com, a.kondratov@postgrespro.ru
Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
In-Reply-To: <2d5cb0b3-a6e8-9bbb-953f-879f47128faa@oss.nttdata.com>
References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com> <CALj2ACVKQeXJ2okDDDiSC5y6i1tfd3P+n7-5iwqnQ=JiOxUyMA@mail.gmail.com> <160467818521.7362.11186359886835925531.pgcf@coridan.postgresql.org> <6df6525ca7a4b54a4a39f55e4dd6b3e9@postgrespro.ru> <CALj2ACVODykNQQAuz3Veh5S9J3QfAi4D9CsExguMhYB4-+-YGw@mail.gmail.com> <f58d1df4ae58f6cf3bfa560f923462e0@postgrespro.ru> <CALj2ACX4B9sBTKPg70TzKfPfPJ=ndocU6hY5jii5wDvzW2X2DQ@mail.gmail.com> <c22ad9fcdba6ab768ec2ea86d33d0c18@postgrespro.ru> <CALj2ACW+PzzuqE6YOueNUi5Zek9XTv9P3FXdT4XF3-1JDk4RuA@mail.gmail.com> <CALj2ACU0gf_Xf2sAtrCRhvLc-G42UqLGthDfVC9G1jzUpBcQ1w@mail.gmail.com> <1f29ad3f1d8b969dfde6d500bbd9d82d@postgrespro.ru> <CALj2ACVq99r+s04tWrD8TBG6QOfa=r1j0JXvKbO6JFmrMgdWpg@mail.gmail.com> <be224d0520df0594b0693c95bd19fe0a@postgrespro.ru> <CALj2ACXBgRBxGvyPA=kWF=96h9rdTAcUqBGbkRgwOx_-vyN3+g@mail.gmail.com> <2d5cb0b3-a6e8-9bbb-953f-879f47128faa@oss.nttdata.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox