On Fri, Jan 29, 2021 at 10:42 AM Bharath Rupireddy <bharath.rupireddyforpostg...@gmail.com> wrote: > > > Also, now that I've looked at pgfdw_inval_callback, it scares > > > the heck out of me. Actually disconnecting a connection during > > > a cache inval callback seems quite unsafe --- what if that happens > > > while we're using the connection? > > > > If the connection is still used in the transaction, pgfdw_inval_callback() > > marks it as invalidated and doesn't close it. So I was not thinking that > > this is so unsafe. > > > > The disconnection code in pgfdw_inval_callback() was added in commit > > e3ebcca843 to fix connection leak issue, and it's back-patched. If this > > change is really unsafe, we need to revert it immediately at least from back > > branches because the next minor release is scheduled soon. > > I think we can remove disconnect_pg_server in pgfdw_inval_callback and > make entries only invalidated. Anyways, those connections can get > closed at the end of main txn in pgfdw_xact_callback. Thoughts? > > If okay, I can make a patch for this.
Attaching a patch for this, which can be back patched. With Regards, Bharath Rupireddy. EnterpriseDB: http://www.enterprisedb.com
v1-0001-Fix-connection-closure-issue-in-pgfdw_inval_callb.patch
Description: Binary data