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 1jiD8A-0000Pm-VV for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Jun 2020 08:27:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jiD88-0003Bq-EV for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Jun 2020 08:27:40 +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 1jiD88-0003Bg-87; Mon, 08 Jun 2020 08:27:40 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jiD83-000462-Sy; Mon, 08 Jun 2020 08:27:39 +0000 Received: by mail-pl1-x642.google.com with SMTP id y18so6374156plr.4; Mon, 08 Jun 2020 01:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:to:subject:from:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=luvB/U0RJptjQhqG5wmWTad80esTdjQ8GDqVty2i0o4=; b=NI9BjHTA+XGxQ/Z6VTblboNHOaxOHJeCGQjKBCNXMJn7grDFXOzwRiYmdW7/OVcEqh gUnXqgWOocbpxyXX53SwJaR/qV+Kh5m3Du1caAF3tQA23aWO3LxA67VNSxJVgW0JSDsl x9+X3eJwCUZELR1xigDXJ+VPyU8ZUgFn4Aa8wXsejtZbFQ+VmUdIdURX5TfMLKJHWHU3 alDc4VwlFZn2Nm00RRoM5C9Sywt9fP9mztUg9uz7lmA5SMVXCScmH6sAdVxrRm9snNL0 UDxd0sNeuVXNsRLU6vQQrEbYrHIPVHrbqSMJS+XvHUMnI1H1GvRBCrJmdpf71PfezIDv PFTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:to:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=luvB/U0RJptjQhqG5wmWTad80esTdjQ8GDqVty2i0o4=; b=NdZHUD436Xxqb2vv/aeiik1roxSgrT2De1Od026Kj0ulYLPqA9z5P86nMTwPF6Gydi V5ZTAY63uu/urYUNdWXFjKRWzuP1f11dpyCEMmi5l7lgPYDF02yyZLI2COUph3d+FPze zsbkrr5bxILrMSgYOtv710l/tqKYw0kAWWcc1fNI/RLaf3LXyPh9CAOFj2yKl08Luz/d 6a1iJBjnxenWxwxnjhDZsbmtkZmILs6BSlKfWoES7BvL18TjYvozxg6Yv7BJfN/Gjq1k 8MzCUqACuEGPHKJCxM1NOYTVZROk9ZlhaQEa9ha80FWlg9hubnWcvdWKJ6Ubt8SubkAJ O1QQ== X-Gm-Message-State: AOAM5332J54JKc+I+nIg7fPnIQ/JPF29E0NlOUwwpEoeN8TpSRPSgyQU WizIiyg17XCEV/Fwh5BYWHE= X-Google-Smtp-Source: ABdhPJwXL5frKSwwqzfp5nIVe5hfL+hUBjWn1H/zZXoRwgcLndRYSFL9FbQw5Mqbiwz3rQFNicPAOw== X-Received: by 2002:a17:90a:1ac3:: with SMTP id p61mr16599358pjp.23.1591604853968; Mon, 08 Jun 2020 01:27:33 -0700 (PDT) Received: from localhost (q061065.dynamic.ppp.asahi-net.or.jp. [203.181.61.65]) by smtp.gmail.com with ESMTPSA id a3sm3314218pfi.77.2020.06.08.01.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2020 01:27:32 -0700 (PDT) Date: Mon, 08 Jun 2020 17:27:30 +0900 (JST) Message-Id: <20200608.172730.68580977059033.horikyota.ntt@gmail.com> To: fabio.vianello@salvagninigroup.com, pgsql-bugs@lists.postgresql.org, pgsql-hackers@lists.postgresql.org Subject: Re: BUG #16481: Stored Procedure Triggered by Logical Replication is Unable to use Notification Events From: Kyotaro Horiguchi In-Reply-To: <16481-8bbe054e7bc0cb3c@postgresql.org> References: <16481-8bbe054e7bc0cb3c@postgresql.org> User-Agent: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Jun__8_17_27_30_2020_370)--" Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ----Next_Part(Mon_Jun__8_17_27_30_2020_370)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello. It seems to me a bug. At Fri, 05 Jun 2020 11:05:14 +0000, PG Bug reporting form wrote in > The following bug has been logged on the website: > > Bug reference: 16481 > Logged by: Fabio Vianello > Email address: fabio.vianello@salvagninigroup.com > PostgreSQL version: 12.3 > Operating system: Windows 10 > Description: > > About the bug BUG #15293, on PostgreSQL version 10.4 and 11.2 as describe > below, we found the same issue on the PostgreSQL version 12.3. The HEAD behaves the same way. > Is it a feature? > Becasue in the documentation we didn't found any constraint that says that > we can not use NOTIFY/LISTEN on logical replication tables. > > "When using logical replication a stored procedure executed on the replica > is > unable to use NOTIFY to send messages to other listeners. The stored > procedure does execute as expected but the pg_notify() doesn't appear to > have any effect. If an insert is run on the replica side the trigger > executes the stored procedure as expected and the NOTIFY correctly > notifies > listeners. The message is actually queued, but logical replication worker doesn't signal that to listener backends. If any ordinary session sent a message to the same listener after that, both messages would be shown at once. That can be fixed by calling ProcessCompletedNotifies() in apply_handle_commit. The function has a code to write out notifications to connected clients but it doesn't nothing on logical replication workers. regards. -- Kyotaro Horiguchi NTT Open Source Software Center ----Next_Part(Mon_Jun__8_17_27_30_2020_370)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-Signal-notifications-from-logical-replication-worker.patch"