Re: postgres_fdw - cached connection leaks if the associated user mapping/foreign server is dropped

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: postgres_fdw - cached connection leaks if the associated user mapping/foreign server is dropped
Date: 2020-12-28 11:05:49
Message-ID: 8b2aa1aa-c638-12a8-cb56-ea0f0a5019cf@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020/12/24 23:45, Fujii Masao wrote:
>
>
> On 2020/12/24 23:30, Bharath Rupireddy wrote:
>> On Thu, Dec 24, 2020 at 7:43 PM Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
>>> Even when we're in the midst of transaction, if that transaction has not used
>>> the cached connections yet, we close them immediately. So, to make the
>>> comment more precise, what about updating the comment as follows?
>>>
>>> ---------------------
>>>       After a change to a pg_foreign_server or pg_user_mapping catalog entry,
>>>       close connections depending on that entry immediately if current
>>>       transaction has not used those connections yet. Otherwise, mark those
>>>       connections as invalid and then make pgfdw_xact_callback() close them
>>>       at the end of current transaction, since they cannot be closed in the midst
>>>       of a transaction using them. Closed connections will be remade at the next
>>>       opportunity if necessary.
>>> ---------------------
>>
>> Done.
>>
>>> +                       /*
>>> +                        * Close the connection if it's not in midst of a xact. Otherwise
>>> +                        * mark it as invalid so that it can be disconnected at the end of
>>> +                        * main xact in pgfdw_xact_callback().
>>> +                        */
>>>
>>> Because of the same reason as the above, what about updating this comment
>>> as follows?
>>>
>>> ---------------------
>>>       Close the connection immediately if it's not used yet in this transaction.
>>>       Otherwise mark it as invalid so that pgfdw_xact_callback() can close it
>>>       at the end of this transaction.
>>> ---------------------
>>
>> Done.
>>
>> Attaching v3 patch. Please have a look. Thanks!
>
> Thanks a lot! Barring any objection, I will commit this version.

Pushed. Thanks!

Regards,

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2020-12-28 11:06:30 Re: Disable WAL logging to speed up data loading
Previous Message Masahiko Sawada 2020-12-28 10:47:39 Re: [doc] adding way to examine the plan type of prepared statements