Re: BUG #15293: Stored Procedure Triggered by Logical Replication is Unable to use Notification Events
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Sergei Kornilov <sk@zsrv.org>, pgsql-hackers@postgresql.org, Peter Eisentraut <peter_e@gmx.net>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Marc Dean <marc.dean.jr@gmail.com>, Petr Jelinek <petr@2ndquadrant.com>, "michael.paul.powers@gmail.com" <michael.paul.powers@gmail.com>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2018-07-24T19:27:40Z
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
Commits
-
Disallow LISTEN in background workers.
- e06cc024bd33 13.5 landed
- d84d62b6225b 14.0 landed
- 1316be28664f 15.0 landed
-
Send NOTIFY signals during CommitTransaction.
- 63f28776cb9f 13.5 landed
- 2e4eae87d02f 15.0 landed
- 0eff10a00844 14.0 landed
-
Make some efficiency improvements in LISTEN/NOTIFY.
- 51004c7172b5 13.0 cited