Skip to content

Commit

Permalink
Merge pull request #48 from aiven/0xlianhu-BF-2380-prune-stuck-when-l…
Browse files Browse the repository at this point in the history
…ost-migration-source

Add parameter to pg_drop_subscription to specify if drop replication slot together
  • Loading branch information
alexole authored Jan 29, 2024
2 parents 797926e + 318cb22 commit 2ad4fc1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
short_ver = 1.1.10
last_ver = 1.1.9
short_ver = 1.1.11
last_ver = 1.1.10
long_ver = $(shell git describe --long 2>/dev/null || echo $(short_ver)-0-unknown-g`git describe --always`)
generated = aiven_extras.control \
sql/aiven_extras--$(short_ver).sql \
Expand Down
1 change: 1 addition & 0 deletions sql/aiven_extras--1.1.9--1.1.10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- NOOP
8 changes: 6 additions & 2 deletions sql/aiven_extras.sql
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ END;
$$;

DROP FUNCTION IF EXISTS aiven_extras.pg_drop_subscription(TEXT);
DROP FUNCTION IF EXISTS aiven_extras.pg_drop_subscription(TEXT, BOOLEAN);
CREATE FUNCTION aiven_extras.pg_drop_subscription(
arg_subscription_name TEXT
arg_subscription_name TEXT,
arg_drop_repl_slot BOOLEAN = TRUE
)
RETURNS VOID LANGUAGE plpgsql
SECURITY DEFINER
Expand All @@ -191,7 +193,9 @@ BEGIN
EXECUTE pg_catalog.format('ALTER SUBSCRIPTION %I DISABLE', arg_subscription_name);
EXECUTE pg_catalog.format('ALTER SUBSCRIPTION %I SET (slot_name = NONE)', arg_subscription_name);
EXECUTE pg_catalog.format('DROP SUBSCRIPTION %I', arg_subscription_name);
PERFORM aiven_extras.dblink_slot_create_or_drop(l_subconninfo, l_slot_name, 'drop');
IF (arg_drop_repl_slot IS TRUE) THEN
PERFORM aiven_extras.dblink_slot_create_or_drop(l_subconninfo, l_slot_name, 'drop');
END IF;
END;
$$;

Expand Down

0 comments on commit 2ad4fc1

Please sign in to comment.