Relax some transactional limications on activate node

We already enforce EnsureSequentialModeMetadataOperations(), and given that all activate node is transaction, we should be fine
pull/5674/head
Onder Kalaci 2022-02-01 15:39:06 +01:00
parent 34d91009ed
commit 650243927c
3 changed files with 29 additions and 8 deletions

View File

@ -787,7 +787,6 @@ SyncDistributedObjectsToNode(WorkerNode *workerNode)
return; return;
} }
EnsureNoModificationsHaveBeenDone();
EnsureSequentialModeMetadataOperations(); EnsureSequentialModeMetadataOperations();
Assert(ShouldPropagate()); Assert(ShouldPropagate());

View File

@ -464,7 +464,11 @@ SELECT create_reference_table('replicate_reference_table_insert');
BEGIN; BEGIN;
INSERT INTO replicate_reference_table_insert VALUES(1); INSERT INTO replicate_reference_table_insert VALUES(1);
SELECT 1 FROM master_add_node('localhost', :worker_2_port); SELECT 1 FROM master_add_node('localhost', :worker_2_port);
ERROR: cannot open new connections after the first modification command within a transaction ?column?
---------------------------------------------------------------------
1
(1 row)
ROLLBACK; ROLLBACK;
DROP TABLE replicate_reference_table_insert; DROP TABLE replicate_reference_table_insert;
-- test COPY then adding a new node in a transaction -- test COPY then adding a new node in a transaction
@ -479,7 +483,11 @@ SET citus.enable_local_execution = 'off';
BEGIN; BEGIN;
COPY replicate_reference_table_copy FROM STDIN; COPY replicate_reference_table_copy FROM STDIN;
SELECT 1 FROM master_add_node('localhost', :worker_2_port); SELECT 1 FROM master_add_node('localhost', :worker_2_port);
ERROR: cannot open new connections after the first modification command within a transaction ?column?
---------------------------------------------------------------------
1
(1 row)
ROLLBACK; ROLLBACK;
RESET citus.enable_local_execution; RESET citus.enable_local_execution;
DROP TABLE replicate_reference_table_copy; DROP TABLE replicate_reference_table_copy;
@ -494,7 +502,11 @@ SELECT create_reference_table('replicate_reference_table_ddl');
BEGIN; BEGIN;
ALTER TABLE replicate_reference_table_ddl ADD column2 int; ALTER TABLE replicate_reference_table_ddl ADD column2 int;
SELECT 1 FROM master_add_node('localhost', :worker_2_port); SELECT 1 FROM master_add_node('localhost', :worker_2_port);
ERROR: cannot open new connections after the first modification command within a transaction ?column?
---------------------------------------------------------------------
1
(1 row)
ROLLBACK; ROLLBACK;
DROP TABLE replicate_reference_table_ddl; DROP TABLE replicate_reference_table_ddl;
-- test DROP table after adding new node in a transaction -- test DROP table after adding new node in a transaction

View File

@ -156,7 +156,7 @@ SELECT * FROM test_matview;
(1 row) (1 row)
SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'events%' ORDER BY logicalrelid::text; SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'events%' ORDER BY logicalrelid::text;
logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted
--------------------------------------------------------------------- ---------------------------------------------------------------------
events | h | {VAR :varno 1 :varattno 1 :vartype 1184 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 1390012 | s | f events | h | {VAR :varno 1 :varattno 1 :vartype 1184 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 1390012 | s | f
events_2021_feb | h | {VAR :varno 1 :varattno 1 :vartype 1184 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 1390012 | s | f events_2021_feb | h | {VAR :varno 1 :varattno 1 :vartype 1184 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 1390012 | s | f
@ -468,7 +468,9 @@ BEGIN;
(1 row) (1 row)
SELECT start_metadata_sync_to_node('localhost', :worker_1_port); SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
ERROR: cannot open new connections after the first modification command within a transaction 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';"
ROLLBACK; ROLLBACK;
-- this is safe because start_metadata_sync_to_node already switches to -- this is safe because start_metadata_sync_to_node already switches to
-- sequential execution -- sequential execution
@ -539,7 +541,11 @@ BEGIN;
-- sync at the end of the tx -- sync at the end of the tx
SELECT start_metadata_sync_to_node('localhost', :worker_1_port); SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
ERROR: cannot open new connections after the first modification command within a transaction start_metadata_sync_to_node
---------------------------------------------------------------------
(1 row)
ROLLBACK; ROLLBACK;
-- multi-shard commands are not allowed with start_metadata_sync -- multi-shard commands are not allowed with start_metadata_sync
BEGIN; BEGIN;
@ -576,7 +582,11 @@ BEGIN;
-- sync at the end of the tx -- sync at the end of the tx
SELECT start_metadata_sync_to_node('localhost', :worker_1_port); SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
ERROR: cannot open new connections after the first modification command within a transaction start_metadata_sync_to_node
---------------------------------------------------------------------
(1 row)
ROLLBACK; ROLLBACK;
-- cleanup -- cleanup
\c - - - :master_port \c - - - :master_port