pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
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, 29 Jan 2021 15:08:04 +0900
Message-ID: <2289b85d-7597-bfd6-aa5f-40f516a91ddc@oss.nttdata.com> (raw)
In-Reply-To: <CALj2ACUMga3eq2-jBDk3poKoq1oFk8dKZTbubZr=obfPYe+ZVA@mail.gmail.com>
References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com>
	<CALj2ACVr+vo+D46uLEATX5fVFPCQRiuKRydxnSy7E6ZwUzBT=w@mail.gmail.com>
	<39259f30-897c-ceaf-8a1e-78fe2db398cb@oss.nttdata.com>
	<CALj2ACUwqO74-amff63Lr1VU1F7WrWEK_28+iT_Ubf8htjZzLg@mail.gmail.com>
	<2147113.1611644754@sss.pgh.pa.us>
	<1b4d7c4f-a9f9-08f0-295d-de6ec0d5def5@oss.nttdata.com>
	<CALj2ACWq4+T-M1cTDDdHm2wBcYCD1fUhpONg11UAH1L-+MoEBw@mail.gmail.com>
	<3c20e3e6-1127-17f4-7725-a860b394076c@oss.nttdata.com>
	<73fc5ae4-3c54-1262-4533-f8c547de2e60@oss.nttdata.com>
	<CALj2ACWFX8wjEKmK8LQ-ZNVJqGt_Zy=1-cBhKE3XTJ+At_VN-w@mail.gmail.com>
	<2688508.1611865371@sss.pgh.pa.us>
	<CALj2ACWhoQtyZdsCZNLDLOnRjCBcoscrc3H0qU4=7f23UZcF9g@mail.gmail.com>
	<2724627.1611886184@sss.pgh.pa.us>
	<fbfdf4e2-37fb-a3f1-f6a0-3f9bf089e356@oss.nttdata.com>
	<CALj2ACVL7PZO+gOj7Jrhshm79TjTpj_6CJDqtf34VgjQasX1DA@mail.gmail.com>
	<6e9c9d45-c612-639a-f741-7798013c0ae4@oss.nttdata.com>
	<CALj2ACUMga3eq2-jBDk3poKoq1oFk8dKZTbubZr=obfPYe+ZVA@mail.gmail.com>



On 2021/01/29 14:53, Bharath Rupireddy wrote:
> On Fri, Jan 29, 2021 at 10:55 AM Fujii Masao
> <masao.fujii@oss.nttdata.com> wrote:
>>>> BTW, even if we change pgfdw_inval_callback() so that it doesn't close
>>>> the connection at all, ISTM that the results of postgres_fdw_get_connections()
>>>> would not be stable because entry->invalidated would vary based on
>>>> whether CLOBBER_CACHE_ALWAYS is used or not.
>>>
>>> Yes, after the above change (removing disconnect_pg_server in
>>> pgfdw_inval_callback), our tests don't get stable because
>>> postgres_fdw_get_connections shows the valid state of the connections.
>>> I think we can change postgres_fdw_get_connections so that it only
>>> shows the active connections server name but not valid state. Because,
>>> the valid state is something dependent on the internal state change
>>> and is not consistent with the user expectation but we are exposing it
>>> to the user.  Thoughts?
>>
>> I don't think that's enough because even the following simple
>> queries return the different results, depending on whether
>> CLOBBER_CACHE_ALWAYS is used or not.
>>
>>       SELECT * FROM ft6;  -- ft6 is the foreign table
>>       SELECT server_name FROM postgres_fdw_get_connections();
>>
>> When CLOBBER_CACHE_ALWAYS is used, postgres_fdw_get_connections()
>> returns no records because the connection is marked as invalidated,
>> and then closed at xact callback in SELECT query. Otherwise,
>> postgres_fdw_get_connections() returns at least one connection that
>> was established in the SELECT query.
> 
> Right. In that case, after changing postgres_fdw_get_connections() so
> that it doesn't output the valid state of the connections at all, we

You're thinking to get rid of "valid" column? Or hide it from the test query
(e.g., SELECT server_name from postgres_fdw_get_connections())?

> can have all the new function test cases inside an explicit txn block.
> So even if the clobber cache invalidates the connections, they don't
> get closed until the end of main xact, the tests will be stable.
> Thoughts?

Also if there are cached connections before starting that transaction,
they should be closed or established again before executing
postgres_fdw_get_connections(). Otherwise, those connections are
returned from postgres_fdw_get_connections() when
CLOBBER_CACHE_ALWAYS is not used, but not when it's used.

Regards,

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





view thread (175+ messages)  latest in thread

Message-ID: <2289b85d-7597-bfd6-aa5f-40f516a91ddc@oss.nttdata.com>
Permalink:  ../2289b85d-7597-bfd6-aa5f-40f516a91ddc@oss.nttdata.com/
Also on:    postgresql.org/message-id/2289b85d-7597-bfd6-aa5f-40f516a91ddc@oss.nttdata.com

 · 

reply

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, tgl@sss.pgh.pa.us
  Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
  In-Reply-To: <2289b85d-7597-bfd6-aa5f-40f516a91ddc@oss.nttdata.com>
  References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com> <39259f30-897c-ceaf-8a1e-78fe2db398cb@oss.nttdata.com> <CALj2ACUwqO74-amff63Lr1VU1F7WrWEK_28+iT_Ubf8htjZzLg@mail.gmail.com> <2147113.1611644754@sss.pgh.pa.us> <1b4d7c4f-a9f9-08f0-295d-de6ec0d5def5@oss.nttdata.com> <CALj2ACWq4+T-M1cTDDdHm2wBcYCD1fUhpONg11UAH1L-+MoEBw@mail.gmail.com> <3c20e3e6-1127-17f4-7725-a860b394076c@oss.nttdata.com> <73fc5ae4-3c54-1262-4533-f8c547de2e60@oss.nttdata.com> <CALj2ACWFX8wjEKmK8LQ-ZNVJqGt_Zy=1-cBhKE3XTJ+At_VN-w@mail.gmail.com> <2688508.1611865371@sss.pgh.pa.us> <CALj2ACWhoQtyZdsCZNLDLOnRjCBcoscrc3H0qU4=7f23UZcF9g@mail.gmail.com> <2724627.1611886184@sss.pgh.pa.us> <fbfdf4e2-37fb-a3f1-f6a0-3f9bf089e356@oss.nttdata.com> <CALj2ACVL7PZO+gOj7Jrhshm79TjTpj_6CJDqtf34VgjQasX1DA@mail.gmail.com> <6e9c9d45-c612-639a-f741-7798013c0ae4@oss.nttdata.com> <CALj2ACUMga3eq2-jBDk3poKoq1oFk8dKZTbubZr=obfPYe+ZVA@mail.gmail.com> <2289b85d-7597-bfd6-aa5f-40f516a91ddc@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