From a43cab7e715ed3fdf2f28aef3d79fb5e30c7c129 Mon Sep 17 00:00:00 2001 From: Sameer Awasekar Date: Thu, 19 May 2022 17:05:42 +0530 Subject: [PATCH] Add DELETE scenario --- src/backend/distributed/shardsplit/pgoutput.c | 7 +++-- .../split_shard_replication_setup.out | 28 +++++++++++++++++++ .../sql/split_shard_replication_setup.sql | 15 +++++++++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/backend/distributed/shardsplit/pgoutput.c b/src/backend/distributed/shardsplit/pgoutput.c index b8c6cb2df..6c1b05b0c 100644 --- a/src/backend/distributed/shardsplit/pgoutput.c +++ b/src/backend/distributed/shardsplit/pgoutput.c @@ -255,10 +255,11 @@ ShouldSlotHandleChange(char *slotName, ReorderBufferChange *change) return true; } + /* -* split_change function emits the incoming tuple change -* to the appropriate destination shard. -*/ + * split_change function emits the incoming tuple change + * to the appropriate destination shard. + */ static void split_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change) diff --git a/src/test/regress/expected/split_shard_replication_setup.out b/src/test/regress/expected/split_shard_replication_setup.out index ab9bfaf0c..09114c715 100644 --- a/src/test/regress/expected/split_shard_replication_setup.out +++ b/src/test/regress/expected/split_shard_replication_setup.out @@ -199,3 +199,31 @@ SELECT * from table_to_split_3; 500 | a (2 rows) +-- Delete data from table_to_split_1 from worker1 +\c - - - :worker_1_port +SET search_path TO citus_split_shard_by_split_points; +DELETE FROM table_to_split_1; +SELECT pg_sleep(10); + pg_sleep +--------------------------------------------------------------------- + +(1 row) + +-- Child shard rows should be deleted +\c - - - :worker_2_port +SET search_path TO citus_split_shard_by_split_points; +SELECT * FROM table_to_split_1; + id | value +--------------------------------------------------------------------- +(0 rows) + +SELECT * FROM table_to_split_2; + id | value +--------------------------------------------------------------------- +(0 rows) + +SELECT * FROM table_to_split_3; + id | value +--------------------------------------------------------------------- +(0 rows) + diff --git a/src/test/regress/sql/split_shard_replication_setup.sql b/src/test/regress/sql/split_shard_replication_setup.sql index eb5ada6cf..df104fc11 100644 --- a/src/test/regress/sql/split_shard_replication_setup.sql +++ b/src/test/regress/sql/split_shard_replication_setup.sql @@ -135,4 +135,17 @@ select pg_sleep(10); SET search_path TO citus_split_shard_by_split_points; SELECT * from table_to_split_1; -- should alwasy have zero rows SELECT * from table_to_split_2; -SELECT * from table_to_split_3; \ No newline at end of file +SELECT * from table_to_split_3; + +-- Delete data from table_to_split_1 from worker1 +\c - - - :worker_1_port +SET search_path TO citus_split_shard_by_split_points; +DELETE FROM table_to_split_1; +SELECT pg_sleep(10); + +-- Child shard rows should be deleted +\c - - - :worker_2_port +SET search_path TO citus_split_shard_by_split_points; +SELECT * FROM table_to_split_1; +SELECT * FROM table_to_split_2; +SELECT * FROM table_to_split_3;