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 1fi2yP-00006q-O9 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jul 2018 19:27:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fi2yN-0002Oa-Fo for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jul 2018 19:27:51 +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.89) (envelope-from ) id 1fi2yM-0002OT-9O for pgsql-bugs@lists.postgresql.org; Tue, 24 Jul 2018 19:27:51 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi2yG-0003pi-OB for pgsql-bugs@lists.postgresql.org; Tue, 24 Jul 2018 19:27:49 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id BA409211E5; Tue, 24 Jul 2018 15:27:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 24 Jul 2018 15:27:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=E74EFHWjnRkbgK5GK7j6nxDzyg/gsFGNXFrBxycbv1Q=; b=VXZtAx6g +tdynDJyvFF2Qg+czJDK7WUifcLX52Rprutjz//m43TpTDGzMia+FfrYdeTF5pNR ttG3kdlTtJ/oCDtcsFuRwhhpV5Eq3JW0/h/KriuIlezTd5cIt5JBUu2j3OZbdljj yJ6pUwMazss4xbJDr4FmGnYmLfweZeFIoowzJ6x4x0K8RXSRIJnV/nLtrW7XIbLC p9Au4UcUVlF+I0tjlFIAyh1UOqc+B9OvOTFpE6SKqiEwt7am82+06TRwr/it97G4 o+B3QPwTfLMybX0CLkSEZzHywTaIhhoILGVm/Mx42IT7pAhUw6xq6LqLah3xKxY1 /C5waFWSZN8ptA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=E74EFHWjnRkbgK5GK7j6nxDzyg/gs FGNXFrBxycbv1Q=; b=EKJLZ9Tnz/fZ5mhVg+dOwh+xEeN2AI/6JPBseJmTUDrzJ s+8DGyYUNNqqVF9YwnxOctvgUxGHu+tEqE9pH4itJLNGzYFdU6Mv3UxgCc+jClPu qQZz8mkCDPuNcMsXJ/gqe2ZfdqCh9a5ssX46jAki8rwB363pumGW3EQQ9KnZWipK gcCi8XM0GAC8CoiuTuBMnc0rHFsPv5bCMVGtOMnU7oi/M+HSJINVtZutgvoblUDY kZ7fnuZyIx84UDSn2T7IgnJ6wlEdXhkA5oyEDuhQYgCkP1M51U7GwdisROzUv0Xs WB+jsqPI0SZqWjTL4aUsCESS1bMIS3hl976S6Iigw== X-ME-Proxy: X-ME-Sender: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 69564E40A1; Tue, 24 Jul 2018 15:27:41 -0400 (EDT) Date: Tue, 24 Jul 2018 12:27:40 -0700 From: Andres Freund To: Sergei Kornilov , pgsql-hackers@postgresql.org, Peter Eisentraut , Tom Lane Cc: 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 Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <648481532456538@myt5-0fa3e541b8b9.qloud-c.yandex.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Tom, Peter, On 2018-07-24 21:22:18 +0300, Sergei Kornilov wrote: > in fact, I've already tried to build fix. Adding ProcessCompletedNotifies to apply_handle_commit fixed this issue and i think this is right place. In src/backend/tcop/postgres.c we call ProcessCompletedNotifies similar way after commit. This change pass make check-world. > So i attach my two line patch. > diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c > index 6ca6cdc..e54bd90 100644 > --- a/src/backend/replication/logical/worker.c > +++ b/src/backend/replication/logical/worker.c > @@ -37,6 +37,7 @@ > > #include "commands/tablecmds.h" > #include "commands/trigger.h" > +#include "commands/async.h" > > #include "executor/executor.h" > #include "executor/nodeModifyTable.h" > @@ -490,6 +491,7 @@ apply_handle_commit(StringInfo s) > replorigin_session_origin_timestamp = commit_data.committime; > > CommitTransactionCommand(); > + ProcessCompletedNotifies(); > pgstat_report_stat(false); > > store_flush_position(commit_data.end_lsn); That's probably reasonable for the back branches (although I'd put the store_flush_position before). 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? Greetings, Andres Freund