Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Zhihong Yu <zyu(at)yugabyte(dot)com>, Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>, "Hou, Zhijie" <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
Date: 2021-01-20 09:54:09
Message-ID: 0c53c3da-9bfe-82f0-1190-5f029e92a816@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021/01/20 17:41, Bharath Rupireddy wrote:
> On Wed, Jan 20, 2021 at 11:53 AM Fujii Masao
> <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
>> So, furthermore, we can use hash_search() to find the target cached
>> connection, instead of using hash_seq_search(), when the server name
>> is given. This would simplify the code a bit more? Of course,
>> hash_seq_search() is necessary when closing all the connections, though.
>
> Note that the cache entry key is user mapping oid and to use
> hash_search() we need the user mapping oid. But in
> postgres_fdw_disconnect we can get server oid and we can also get user
> mapping id using GetUserMapping, but it requires
> GetUserId()/CurrentUserId as an input, I doubt we will have problems
> if CurrentUserId is changed somehow with the change of current user in
> the session. And user mapping may be dropped but still the connection
> can exist if it's in use, in that case GetUserMapping fails in cache
> lookup.
>
> And yes, disconnecting all connections requires hash_seq_search().
>
> Keeping above in mind, I feel we can do hash_seq_search(), as we do
> currently, even when the server name is given as input. This way, we
> don't need to bother much on the above points.
>
> Thoughts?

Thanks for explaining this! You're right. I'd withdraw my suggestion.

Regards,

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Nancarrow 2021-01-20 09:57:41 Re: Parallel INSERT (INTO ... SELECT ...)
Previous Message Thomas Munro 2021-01-20 09:49:58 Re: [bug?] EXPLAIN outputs 0 for rows and width in cost estimate for update nodes