Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXCM3-0005gq-FW for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jul 2017 20:10:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dXCM2-0005nI-Qk for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jul 2017 20:10:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dXCKV-0002xr-Tp for pgsql-hackers@postgresql.org; Mon, 17 Jul 2017 20:09:19 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dXCKO-0000Ab-IB for pgsql-hackers@postgresql.org; Mon, 17 Jul 2017 20:09:19 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v6HK94VC009898; Mon, 17 Jul 2017 16:09:04 -0400 From: Tom Lane To: Kyotaro HORIGUCHI cc: ashutosh.bapat@enterprisedb.com, pgsql-hackers@postgresql.org, Langote_Amit_f8@lab.ntt.co.jp, fcs1@poczta.onet.pl Subject: Re: PgFDW connection invalidation by ALTER SERVER/ALTER USER MAPPING In-reply-to: <20170714.173424.239554763.horiguchi.kyotaro@lab.ntt.co.jp> References: <20170713.134249.97825982.horiguchi.kyotaro@lab.ntt.co.jp> <20170713.182300.148193868.horiguchi.kyotaro@lab.ntt.co.jp> <20170714.173424.239554763.horiguchi.kyotaro@lab.ntt.co.jp> Comments: In-reply-to Kyotaro HORIGUCHI message dated "Fri, 14 Jul 2017 17:34:24 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9896.1500322144.1@sss.pgh.pa.us> Date: Mon, 17 Jul 2017 16:09:04 -0400 Message-ID: <9897.1500322144@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Kyotaro HORIGUCHI writes: > This is the revased and revised version of the previous patch. A few more comments: * Per the spec for CacheRegisterSyscacheCallback, a zero hash value means to flush all associated state. This isn't handling that case correctly. Even when you are given a specific hash value, I think exiting after finding one match is incorrect: there could be multiple connections to the same server with different user mappings, or vice versa. * I'm not really sure that it's worth the trouble to pay attention to the hash value at all. Very few other syscache callbacks do, and the pg_server/pg_user_mapping catalogs don't seem likely to have higher than average traffic. * Personally I'd be inclined to register the callbacks at the same time the hashtables are created, which is a pattern we use elsewhere ... in fact, postgres_fdw itself does it that way for the transaction related callbacks, so it seems a bit weird that you are going in a different direction for these callbacks. That way avoids the need to depend on a _PG_init function and means that the callbacks don't have to worry about the hashtables not being valid. Also, it seems a bit pointless to have separate layers of postgresMappingSysCallback and InvalidateConnectionForMapping functions. * How about some regression test cases? You couldn't really exercise cross-session invalidation easily, but I don't think you need to. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers