Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khrej-0001pB-5k for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Nov 2020 10:04:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khrei-00070L-41 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Nov 2020 10:04:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khreh-00070E-QM for pgsql-hackers@lists.postgresql.org; Wed, 25 Nov 2020 10:04:07 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khref-000599-2G for pgsql-hackers@lists.postgresql.org; Wed, 25 Nov 2020 10:04:07 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id ED76521C552C; Wed, 25 Nov 2020 13:04:01 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1606298641; bh=UzeJsUUGZbCOKkRFtRcFtF0FqkyJqjuhv8ikZo65vUs=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=T0WD5Ot2rpV26fu2bkXa0pSH0cfiWyZABiuUMMQ76QFxVdU/B6hpRch08SMJTdhOV 0XSa1nh5jrMuyXsKAXRyFqyMLpko8FCT/0UI+u0AzsCzX48/4QZeVxWDxL66T5s6lP pgrDgQ/yAeT3qSq06OzmnSBlMLhNjDqqGnB2rTmk= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 25 Nov 2020 13:04:01 +0300 From: Alexey Kondratov To: Bharath Rupireddy Cc: Craig Ringer , PostgreSQL Hackers Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit In-Reply-To: References: <160467818521.7362.11186359886835925531.pgcf@coridan.postgresql.org> <6df6525ca7a4b54a4a39f55e4dd6b3e9@postgrespro.ru> <1f29ad3f1d8b969dfde6d500bbd9d82d@postgrespro.ru> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <6e6aa41c9cdde9d4e5572385e108d68e@postgrespro.ru> X-Sender: a.kondratov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-11-25 06:17, Bharath Rupireddy wrote: > On Wed, Nov 25, 2020 at 7:24 AM Craig Ringer > wrote: >> >> A quick thought here. >> >> Would it make sense to add a hook in the DISCARD ALL implementation >> that postgres_fdw can register for? >> >> There's precedent here, since DISCARD ALL already has the same effect >> as SELECT pg_advisory_unlock_all(); amongst other things. >> > > IIUC, then it is like a core(server) function doing some work for the > postgres_fdw module. Earlier in the discussion, one point raised was > that it's better not to have core handling something related to > postgres_fdw. This is the reason we have come up with postgres_fdw > specific function and a GUC, which get defined when extension is > created. Similarly, dblink also has it's own bunch of functions one > among them is dblink_disconnect(). > If I have got Craig correctly, he proposed that we already have a DISCARD ALL statement, which is processed by DiscardAll(), and it releases internal resources known from the core perspective. That way, we can introduce a general purpose hook DiscardAll_hook(), so postgres_fdw can get use of it to clean up its own resources (connections in our context) if needed. In other words, it is not like a core function doing some work for the postgres_fdw module, but rather like a callback/hook, that postgres_fdw is able to register to do some additional work. It can be a good replacement for 0001, but won't it be already an overkill to drop all local caches along with remote connections? I mean, that it would be a nice to have hook from the extensibility perspective, but postgres_fdw_disconnect() still makes sense, since it does a very narrow and specific job. Regards -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company