From f9ff59c6ba69b7609f13746d18c4eac424000a70 Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Fri, 28 Jan 2022 18:13:07 +0300 Subject: [PATCH] Make sure no modification done instead seq one --- .../distributed/metadata/node_metadata.c | 2 +- .../multi_replicate_reference_table.out | 18 +++----------- .../expected/start_stop_metadata_sync.out | 24 ++++--------------- .../regress/sql/start_stop_metadata_sync.sql | 8 ++----- 4 files changed, 11 insertions(+), 41 deletions(-) diff --git a/src/backend/distributed/metadata/node_metadata.c b/src/backend/distributed/metadata/node_metadata.c index a8c2ca8ab..18b1cab04 100644 --- a/src/backend/distributed/metadata/node_metadata.c +++ b/src/backend/distributed/metadata/node_metadata.c @@ -787,7 +787,7 @@ SyncDistributedObjectsToNode(WorkerNode *workerNode) return; } - EnsureSequentialModeMetadataOperations(); + EnsureNoModificationsHaveBeenDone(); Assert(ShouldPropagate()); List *commandList = SyncDistributedObjectsCommandList(workerNode); diff --git a/src/test/regress/expected/multi_replicate_reference_table.out b/src/test/regress/expected/multi_replicate_reference_table.out index aa5d10149..e77ce2df1 100644 --- a/src/test/regress/expected/multi_replicate_reference_table.out +++ b/src/test/regress/expected/multi_replicate_reference_table.out @@ -464,11 +464,7 @@ SELECT create_reference_table('replicate_reference_table_insert'); BEGIN; INSERT INTO replicate_reference_table_insert VALUES(1); SELECT 1 FROM master_add_node('localhost', :worker_2_port); - ?column? ---------------------------------------------------------------------- - 1 -(1 row) - +ERROR: cannot open new connections after the first modification command within a transaction ROLLBACK; DROP TABLE replicate_reference_table_insert; -- test COPY then adding a new node in a transaction @@ -483,11 +479,7 @@ SET citus.enable_local_execution = 'off'; BEGIN; COPY replicate_reference_table_copy FROM STDIN; SELECT 1 FROM master_add_node('localhost', :worker_2_port); - ?column? ---------------------------------------------------------------------- - 1 -(1 row) - +ERROR: cannot open new connections after the first modification command within a transaction ROLLBACK; RESET citus.enable_local_execution; DROP TABLE replicate_reference_table_copy; @@ -502,11 +494,7 @@ SELECT create_reference_table('replicate_reference_table_ddl'); BEGIN; ALTER TABLE replicate_reference_table_ddl ADD column2 int; SELECT 1 FROM master_add_node('localhost', :worker_2_port); - ?column? ---------------------------------------------------------------------- - 1 -(1 row) - +ERROR: cannot open new connections after the first modification command within a transaction ROLLBACK; DROP TABLE replicate_reference_table_ddl; -- test DROP table after adding new node in a transaction diff --git a/src/test/regress/expected/start_stop_metadata_sync.out b/src/test/regress/expected/start_stop_metadata_sync.out index 020e354d1..3cbbf1572 100644 --- a/src/test/regress/expected/start_stop_metadata_sync.out +++ b/src/test/regress/expected/start_stop_metadata_sync.out @@ -468,9 +468,7 @@ BEGIN; (1 row) SELECT start_metadata_sync_to_node('localhost', :worker_1_port); -ERROR: cannot execute metadata syncing operation because there was a parallel operation on a distributed table in the transaction -DETAIL: When modifying metadata, Citus needs to perform all operations over a single connection per node to ensure consistency. -HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" +ERROR: cannot open new connections after the first modification command within a transaction ROLLBACK; -- this is safe because start_metadata_sync_to_node already switches to -- sequential execution @@ -507,9 +505,7 @@ BEGIN; (1 row) ROLLBACK; --- multi-shard commands are allowed with start_metadata_sync --- as long as the start_metadata_sync_to_node executed --- when it is OK to switch to sequential execution +-- multi-shard commands are not allowed with start_metadata_sync BEGIN; -- sync at the start of the tx SELECT start_metadata_sync_to_node('localhost', :worker_1_port); @@ -543,15 +539,9 @@ BEGIN; -- sync at the end of the tx SELECT start_metadata_sync_to_node('localhost', :worker_1_port); - start_metadata_sync_to_node ---------------------------------------------------------------------- - -(1 row) - +ERROR: cannot open new connections after the first modification command within a transaction ROLLBACK; --- multi-shard commands are allowed with start_metadata_sync --- as long as the start_metadata_sync_to_node executed --- when it is OK to switch to sequential execution +-- multi-shard commands are not allowed with start_metadata_sync BEGIN; -- sync at the start of the tx SELECT start_metadata_sync_to_node('localhost', :worker_1_port); @@ -586,11 +576,7 @@ BEGIN; -- sync at the end of the tx SELECT start_metadata_sync_to_node('localhost', :worker_1_port); - start_metadata_sync_to_node ---------------------------------------------------------------------- - -(1 row) - +ERROR: cannot open new connections after the first modification command within a transaction ROLLBACK; -- cleanup \c - - - :master_port diff --git a/src/test/regress/sql/start_stop_metadata_sync.sql b/src/test/regress/sql/start_stop_metadata_sync.sql index b612d15a5..a23eba415 100644 --- a/src/test/regress/sql/start_stop_metadata_sync.sql +++ b/src/test/regress/sql/start_stop_metadata_sync.sql @@ -244,9 +244,7 @@ BEGIN; SELECT create_distributed_table('test_table_rep', 'a'); ROLLBACK; --- multi-shard commands are allowed with start_metadata_sync --- as long as the start_metadata_sync_to_node executed --- when it is OK to switch to sequential execution +-- multi-shard commands are not allowed with start_metadata_sync BEGIN; -- sync at the start of the tx SELECT start_metadata_sync_to_node('localhost', :worker_1_port); @@ -262,9 +260,7 @@ BEGIN; SELECT start_metadata_sync_to_node('localhost', :worker_1_port); ROLLBACK; --- multi-shard commands are allowed with start_metadata_sync --- as long as the start_metadata_sync_to_node executed --- when it is OK to switch to sequential execution +-- multi-shard commands are not allowed with start_metadata_sync BEGIN; -- sync at the start of the tx SELECT start_metadata_sync_to_node('localhost', :worker_1_port);