Merge pull request #5674 from citusdata/minor_fixes_metadata_sync

Minor fixes for metadata syncing
pull/5669/head^2
Önder Kalacı 2022-02-02 11:40:51 +01:00 committed by GitHub
commit 4bb7283af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 10 deletions

View File

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

View File

@ -402,8 +402,7 @@ ErrorIfCurrentUserCanNotDistributeObject(ObjectType type, ObjectAddress *addr,
bool skipAclCheck = false;
Oid idToCheck = InvalidOid;
/* Since we don't handle sequences like object, add it separately */
if (!(SupportedDependencyByCitus(addr) || type == OBJECT_SEQUENCE))
if (!SupportedDependencyByCitus(addr))
{
ereport(ERROR, (errmsg("Object type %d can not be distributed by Citus", type)));
}

View File

@ -464,7 +464,11 @@ 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);
ERROR: cannot open new connections after the first modification command within a transaction
?column?
---------------------------------------------------------------------
1
(1 row)
ROLLBACK;
DROP TABLE replicate_reference_table_insert;
-- test COPY then adding a new node in a transaction
@ -479,7 +483,11 @@ SET citus.enable_local_execution = 'off';
BEGIN;
COPY replicate_reference_table_copy FROM STDIN;
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;
RESET citus.enable_local_execution;
DROP TABLE replicate_reference_table_copy;
@ -494,7 +502,11 @@ 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);
ERROR: cannot open new connections after the first modification command within a transaction
?column?
---------------------------------------------------------------------
1
(1 row)
ROLLBACK;
DROP TABLE replicate_reference_table_ddl;
-- test DROP table after adding new node in a transaction

View File

@ -156,7 +156,7 @@ SELECT * FROM test_matview;
(1 row)
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_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)
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;
-- this is safe because start_metadata_sync_to_node already switches to
-- sequential execution
@ -539,7 +541,11 @@ BEGIN;
-- sync at the end of the tx
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;
-- multi-shard commands are not allowed with start_metadata_sync
BEGIN;
@ -576,7 +582,11 @@ BEGIN;
-- sync at the end of the tx
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;
-- cleanup
\c - - - :master_port