Re: BUG #15293: Stored Procedure Triggered by Logical Replication is Unable to use Notification Events

From: Andres Freund <andres(at)anarazel(dot)de>
To: Sergei Kornilov <sk(at)zsrv(dot)org>, pgsql-hackers(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marc Dean <marc(dot)dean(dot)jr(at)gmail(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, "michael(dot)paul(dot)powers(at)gmail(dot)com" <michael(dot)paul(dot)powers(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15293: Stored Procedure Triggered by Logical Replication is Unable to use Notification Events
Date: 2018-07-24 19:27:40
Message-ID: 20180724192740.6yn2xregaz6yhpc2@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2018-07-24 19:30:27 Re: BUG #15294: Phantom read in serializable transaction when you rename schema.
Previous Message Olav Gjerde 2018-07-24 19:26:05 Re: BUG #15294: Phantom read in serializable transaction when you rename schema.

Browse pgsql-hackers by date

  From Date Subject
Next Message matshyeq 2018-07-24 20:16:22 Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)
Previous Message Robert Haas 2018-07-24 19:19:24 Re: [HACKERS] Two pass CheckDeadlock in contentent case