-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that we drop subscriptions exactly once
when endpoint starts on a new branch. It is essential, because itherwise, we may drop not only inherited, but newly created subscriptions. We cannot rely only on spec.drop_subscriptions_before_start flag, because if for some reason compute restarts inside VM, it will start again with the same spec and flag value. To handle this, we save the fact of the operation in the database in the neon_migration_test.drop_subscriptions_done table. If the table does not exist, we assume that the operation was never performed, so we must do it. If table exists, we check if the operation was performed on the current timelilne. Also adjust the test test_subscriber_branching.py to cover this case.
- Loading branch information
1 parent
b7b80c3
commit 8e200c1
Showing
4 changed files
with
148 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DO $$ | ||
BEGIN | ||
IF NOT EXISTS( | ||
SELECT 1 | ||
FROM pg_catalog.pg_tables | ||
WHERE tablename = 'drop_subscriptions_done' | ||
AND schemaname = 'neon_migration' | ||
) | ||
THEN | ||
CREATE SCHEMA IF NOT EXISTS neon_migration; | ||
ALTER SCHEMA neon_migration OWNER TO cloud_admin; | ||
REVOKE ALL ON SCHEMA neon_migration FROM PUBLIC; | ||
|
||
CREATE TABLE neon_migration.drop_subscriptions_done | ||
(timeline_id text); | ||
END IF; | ||
|
||
INSERT INTO neon_migration.drop_subscriptions_done | ||
VALUES (current_setting('neon.timeline_id')); | ||
END | ||
$$ |
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