Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi55t-0006Ai-Iy for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jul 2018 21:43:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fi55r-0006En-7d for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jul 2018 21:43:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi55q-0006EY-Ta; Tue, 24 Jul 2018 21:43:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi55o-0006c7-En; Tue, 24 Jul 2018 21:43:41 +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 w6OLhUIv013845; Tue, 24 Jul 2018 17:43:30 -0400 From: Tom Lane To: Andres Freund cc: Sergei Kornilov , pgsql-hackers@postgresql.org, Peter Eisentraut , Marc Dean , Petr Jelinek , "michael.paul.powers@gmail.com" , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #15293: Stored Procedure Triggered by Logical Replication is Unable to use Notification Events In-reply-to: <20180724192740.6yn2xregaz6yhpc2@alap3.anarazel.de> References: <153243441449.1404.2274116228506175596@wrigleys.postgresql.org> <45136061532438385@iva3-a2a8aac410a1.qloud-c.yandex.net> <20180724155829.zq22vov6d7erhxsx@alap3.anarazel.de> <648481532456538@myt5-0fa3e541b8b9.qloud-c.yandex.net> <20180724192740.6yn2xregaz6yhpc2@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 24 Jul 2018 12:27:40 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13843.1532468610.1@sss.pgh.pa.us> Date: Tue, 24 Jul 2018 17:43:30 -0400 Message-ID: <13844.1532468610@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > But I wonder if we shouldn't actually move the signalling part of > ProcessCompletedNotifies() into CommitTransactionCommand() in v11. Given > that transactions can now commit without a ready command being sent, due > to the addition of procedures, that kind of seems necessary? Hrm. I have a nasty feeling that that code is dependent on being executed at the outermost logic level. In particular, ProcessCompletedNotifies calls CommitTransactionCommand itself, so your proposal will create infinite recursion. There may be some other issues too. Another question that needs consideration is whether an internal commit should lead to immediate distribution of notifies to our own client. I think it probably mustn't; from the standpoint of the client, its originally-asked-for xact is still in progress, and it's not going to expect any notifies until that ends. So the proposed change is just wrong if you ask me. I agree we need some serious rethinking here. Maybe the fix will end up being just a few lines, but it might take significant restructuring too. regards, tom lane