forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[yugabyte#22040] YSQL: Add yb_restart_commit_ht column in pg_replicat…
…ion_slots view Summary: Summary This is related to the project to support Replication slot API in YSQL (yugabyte#18724). (https://phorge.dev.yugabyte.com/D29194). This is also related to the PG Compatible Logical Replication Consumption project. The schema of the pg_replication_slots view has been modified by adding an extra yb-specific column yb_restart_commit_ht which is a int8. The value of this column is a uint64 representation of the commit Hybrid Time corresponding to the restart_lsn. This can be used by the client (like YB-PG Connector) to perform a consistent snapshot (as of the consistent_point) in the case when a replication slot already exists. UPGRADE/ROLLBACK SAFETY: These changes are protected via the preview flag: ysql_yb_enable_replication_commands Jira: DB-10956 Test Plan: Manual Testing ./yb_build.sh --java-test 'org.yb.pgsql.TestPgReplicationSlot' ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressReplicationSlot' ./yb_build.sh --java-test 'org.yb.pgsql.TestYsqlUpgrade#upgradeIsIdempotent' ./yb_build.sh --java-test 'org.yb.pgsql.TestYsqlUpgrade#upgradeIsIdempotentSingleConn' Reviewers: stiwary, skumar Reviewed By: stiwary Subscribers: yql, ycdcxcluster Differential Revision: https://phorge.dev.yugabyte.com/D34279
- Loading branch information
1 parent
09e46ba
commit 3956dbd
Showing
9 changed files
with
104 additions
and
28 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
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
54 changes: 54 additions & 0 deletions
54
...ql/pgwrapper/ysql_migrations/V50__22040__yb_restart_commit_ht_in_pg_replication_slots.sql
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,54 @@ | ||
BEGIN; | ||
SET LOCAL yb_non_ddl_txn_for_sys_tables_allowed TO true; | ||
|
||
-- Add a column for restart commit ht in pg_get_replication_slots | ||
-- TODO: As a workaround for GHI #13500, we perform a delete + insert instead | ||
-- of an update into pg_proc. Restore to UPDATE once fixed. | ||
DELETE FROM pg_catalog.pg_proc WHERE proname = 'pg_get_replication_slots' AND | ||
pronamespace = 'pg_catalog'::regnamespace; | ||
INSERT INTO pg_catalog.pg_proc ( | ||
oid, proname, pronamespace, proowner, prolang, procost, prorows, provariadic, protransform, | ||
prokind, prosecdef, proleakproof, proisstrict, proretset, provolatile, proparallel, | ||
pronargs, pronargdefaults, prorettype, proargtypes, proallargtypes, proargmodes, | ||
proargnames, proargdefaults, protrftypes, prosrc, probin, proconfig, proacl | ||
) VALUES ( | ||
3781, 'pg_get_replication_slots', 11, 10, 12, 1, 10, 0, '-', 'f', false, false, false, | ||
true, 's', 's', 0, 0, 2249, '', '{19,19,25,26,16,16,23,28,28,3220,3220,25,20}', | ||
'{o,o,o,o,o,o,o,o,o,o,o,o,o}', '{slot_name,plugin,slot_type,datoid,temporary,active, | ||
active_pid,xmin,catalog_xmin,restart_lsn,confirmed_flush_lsn,yb_stream_id,yb_restart_commit_ht}', | ||
NULL, NULL, 'pg_get_replication_slots', NULL, NULL, NULL) | ||
ON CONFLICT DO NOTHING; | ||
COMMIT; | ||
|
||
-- Recreating system views that use pg_get_replication_slots to update their corresponding | ||
-- pg_rewrite entries. | ||
DO $$ | ||
BEGIN | ||
IF NOT EXISTS ( | ||
SELECT TRUE FROM pg_attribute | ||
WHERE attrelid = 'pg_catalog.pg_replication_slots'::regclass | ||
AND attname = 'yb_restart_commit_ht' | ||
AND NOT attisdropped | ||
) THEN | ||
CREATE OR REPLACE VIEW pg_catalog.pg_replication_slots | ||
WITH (use_initdb_acl = true) | ||
AS | ||
SELECT | ||
L.slot_name, | ||
L.plugin, | ||
L.slot_type, | ||
L.datoid, | ||
D.datname AS database, | ||
L.temporary, | ||
L.active, | ||
L.active_pid, | ||
L.xmin, | ||
L.catalog_xmin, | ||
L.restart_lsn, | ||
L.confirmed_flush_lsn, | ||
L.yb_stream_id, | ||
L.yb_restart_commit_ht | ||
FROM pg_get_replication_slots() AS L | ||
LEFT JOIN pg_database D ON (L.datoid = D.oid); | ||
END IF; | ||
END $$; |