-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from jfinzel/bugfix_multi_sub_single_db
Ignore duplicates in queue table to support multiple subscriptions fr… * https://github.com/enova/pgl_ddl_deploy: Ignore duplicates in queue table to support multiple subscriptions from same provider db
- Loading branch information
Showing
20 changed files
with
3,647 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
pgl-ddl-deploy (2.1.0-1) unstable; urgency=medium | ||
|
||
* Fix duplicate issue with multiple subscriptions | ||
|
||
-- Jeremy Finzel <[email protected]> Fri, 19 Feb 2021 11:21:59 -0600 | ||
|
||
pgl-ddl-deploy (2.0.0-2) unstable; urgency=medium | ||
|
||
[ Jeremy Finzel ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-- Allow running regression suite with upgrade paths | ||
\set v `echo ${FROMVERSION:-2.0}` | ||
\set v `echo ${FROMVERSION:-2.1}` | ||
SET client_min_messages = warning; | ||
CREATE EXTENSION pglogical; | ||
CREATE EXTENSION pgl_ddl_deploy VERSION :'v'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* pgl_ddl_deploy--2.0--2.1.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION | ||
\echo Use "CREATE EXTENSION pgl_ddl_deploy" to load this file. \quit | ||
|
||
CREATE OR REPLACE FUNCTION pgl_ddl_deploy.execute_queued_ddl() | ||
RETURNS trigger | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
BEGIN | ||
|
||
/*** | ||
Native logical replication does not support row filtering, so as a result, | ||
we need to do processing downstream to ensure we only process rows we care about. | ||
For example, if we propagate some DDL to system 1 and some other to system 2, | ||
all rows will still come through this trigger. We filter out rows based on | ||
matching pubnames with pg_subscription.subpublications | ||
If a row arrives here (the subscriber), it must mean that it was propagated | ||
***/ | ||
|
||
-- This handles potential duplicates with multiple subscriptions to same publisher db. | ||
IF EXISTS ( | ||
SELECT NEW.* | ||
INTERSECT | ||
SELECT * FROM pgl_ddl_deploy.queue) THEN | ||
RETURN NULL; | ||
END IF; | ||
|
||
IF NEW.message_type = pgl_ddl_deploy.queue_ddl_message_type() AND | ||
(pgl_ddl_deploy.override() OR ((SELECT COUNT(1) FROM pg_subscription s | ||
WHERE subpublications && NEW.pubnames) > 0)) THEN | ||
|
||
-- See https://www.postgresql.org/message-id/CAMa1XUh7ZVnBzORqjJKYOv4_pDSDUCvELRbkF0VtW7pvDW9rZw@mail.gmail.com | ||
IF NEW.message ~* 'pgl_ddl_deploy.notify_subscription_refresh' THEN | ||
INSERT INTO pgl_ddl_deploy.subscriber_logs | ||
(set_name, | ||
provider_pid, | ||
provider_node_name, | ||
provider_set_config_id, | ||
executed_as_role, | ||
subscriber_pid, | ||
executed_at, | ||
ddl_sql, | ||
full_ddl_sql, | ||
succeeded, | ||
error_message) | ||
VALUES | ||
(NEW.pubnames[1], | ||
NULL, | ||
NULL, | ||
NULL, | ||
current_role, | ||
pg_backend_pid(), | ||
current_timestamp, | ||
NEW.message, | ||
NEW.message, | ||
FALSE, | ||
'Unsupported automated ALTER SUBSCRIPTION ... REFRESH PUBLICATION until bugfix'); | ||
ELSE | ||
EXECUTE 'SET ROLE '||quote_ident(NEW.role)||';'; | ||
EXECUTE NEW.message::TEXT; | ||
END IF; | ||
|
||
RETURN NEW; | ||
ELSE | ||
RETURN NULL; | ||
END IF; | ||
|
||
END; | ||
$function$ | ||
; | ||
|
||
|
Oops, something went wrong.