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: Zhihong Yu <zyu@yugabyte.com>
Cc: Alexey Kondratov <a.kondratov@postgrespro.ru>
Cc: Hou, Zhijie <houzj.fnst@cn.fujitsu.com>
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: Thu, 21 Jan 2021 15:47:31 +0900
Message-ID: <153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@oss.nttdata.com> (raw)
In-Reply-To: <CALj2ACVx0+iOsrAA-wXbo3RLAKqUoNvvEd7foJ0vLwOdu8XjXw@mail.gmail.com>
References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com>
	<c2a00f21-a80d-8bce-e2ea-8cd8e16c4da9@oss.nttdata.com>
	<CALj2ACURjjg8wVpfb-s8GE+4ycQcx6z+QGQOM3TC_Cjz+=Lq6w@mail.gmail.com>
	<422884a8-c863-a4d4-cebd-562855c29977@oss.nttdata.com>
	<CALj2ACUv_+qaoYvsy674Aw8Myo-Ydte7b6vRKi3Q8ZmfG+S5Bg@mail.gmail.com>
	<0bc2b366-76d4-9480-5812-6f0de2b3f526@oss.nttdata.com>
	<CALj2ACXMB4Z4ewCeXWx7oOSxzkhqQ4KLeNVZ=NB6=fjhN89n3w@mail.gmail.com>
	<ba9c0824-77b7-16bd-e425-7b1893725eee@oss.nttdata.com>
	<CALj2ACW3p_TLLH_On3Q=EWYoGKLYzi9vxH_isRXYksw5j1mkTQ@mail.gmail.com>
	<0c53c3da-9bfe-82f0-1190-5f029e92a816@oss.nttdata.com>
	<CALj2ACUdk3YJSSW9z7hNbnp53ase4yasNO5UaubUx7WeQtdKuQ@mail.gmail.com>
	<394e56d4-5b8c-57cf-52e2-ea331436882d@oss.nttdata.com>
	<CALj2ACWVy_PGERjsZW+nTKBNKoEWPnRVoc=Bw0M7TorYuoquFQ@mail.gmail.com>
	<0e61fbcc-fca2-18f8-758c-4ed61c664fd7@oss.nttdata.com>
	<CALj2ACVx0+iOsrAA-wXbo3RLAKqUoNvvEd7foJ0vLwOdu8XjXw@mail.gmail.com>



On 2021/01/21 14:46, Bharath Rupireddy wrote:
> On Thu, Jan 21, 2021 at 10:06 AM Fujii Masao
> <masao.fujii@oss.nttdata.com> wrote:
>   > >> +                       if (entry->server_hashvalue == hashvalue &&
>>>> +                               (entry->xact_depth > 0 || result))
>>>> +                       {
>>>> +                               hash_seq_term(&scan);
>>>> +                               break;
>>>>
>>>> entry->server_hashvalue can be 0? If yes, since postgres_fdw_disconnect_all()
>>>> specifies 0 as hashvalue, ISTM that the above condition can be true
>>>> unexpectedly. Can we replace this condition with just "if (!all)"?
>>>
>>> I don't think so entry->server_hashvalue can be zero, because
>>> GetSysCacheHashValue1/CatalogCacheComputeHashValue will not return 0
>>> as hash value. I have not seen someone comparing hashvalue with an
>>> expectation that it has 0 value, for instance see if (hashvalue == 0
>>> || riinfo->oidHashValue == hashvalue).
>>>
>>>    Having if(!all) something like below there doesn't suffice because we
>>> might call hash_seq_term, when some connection other than the given
>>> foreign server connection is in use.
>>
>> No because we check the following condition before reaching that code. No?
>>
>> +               if ((all || entry->server_hashvalue == hashvalue) &&
>>
>>
>> I was thinking that "(entry->xact_depth > 0 || result))" condition is not
>> necessary because "result" is set to true when xact_depth <= 0 and that
>> condition always indicates true.
> 
> I think that condition is too confusing. How about having a boolean
> can_terminate_scan like below?

Thanks for thinking this. But at least for me, "if (!all)" looks not so confusing.
And the comment seems to explain why we can end the scan.

Regards,

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





view thread (175+ messages)  latest in thread

Message-ID: <153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@oss.nttdata.com>
Permalink:  ../153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@oss.nttdata.com/
Also on:    postgresql.org/message-id/153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@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, zyu@yugabyte.com, a.kondratov@postgrespro.ru, houzj.fnst@cn.fujitsu.com
  Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
  In-Reply-To: <153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@oss.nttdata.com>
  References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com> <CALj2ACURjjg8wVpfb-s8GE+4ycQcx6z+QGQOM3TC_Cjz+=Lq6w@mail.gmail.com> <422884a8-c863-a4d4-cebd-562855c29977@oss.nttdata.com> <CALj2ACUv_+qaoYvsy674Aw8Myo-Ydte7b6vRKi3Q8ZmfG+S5Bg@mail.gmail.com> <0bc2b366-76d4-9480-5812-6f0de2b3f526@oss.nttdata.com> <CALj2ACXMB4Z4ewCeXWx7oOSxzkhqQ4KLeNVZ=NB6=fjhN89n3w@mail.gmail.com> <ba9c0824-77b7-16bd-e425-7b1893725eee@oss.nttdata.com> <CALj2ACW3p_TLLH_On3Q=EWYoGKLYzi9vxH_isRXYksw5j1mkTQ@mail.gmail.com> <0c53c3da-9bfe-82f0-1190-5f029e92a816@oss.nttdata.com> <CALj2ACUdk3YJSSW9z7hNbnp53ase4yasNO5UaubUx7WeQtdKuQ@mail.gmail.com> <394e56d4-5b8c-57cf-52e2-ea331436882d@oss.nttdata.com> <CALj2ACWVy_PGERjsZW+nTKBNKoEWPnRVoc=Bw0M7TorYuoquFQ@mail.gmail.com> <0e61fbcc-fca2-18f8-758c-4ed61c664fd7@oss.nttdata.com> <CALj2ACVx0+iOsrAA-wXbo3RLAKqUoNvvEd7foJ0vLwOdu8XjXw@mail.gmail.com> <153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@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