Prevent Transactions in start_metadata_sync_to_node

pull/997/head
Eren Basak 2016-12-02 10:39:11 +03:00
parent c154a91621
commit 4fd086f0af
3 changed files with 24 additions and 2 deletions

View File

@ -73,6 +73,8 @@ start_metadata_sync_to_node(PG_FUNCTION_ARGS)
EnsureSuperUser();
PreventTransactionChain(true, "start_metadata_sync_to_node");
workerNode = FindWorkerNode(nodeNameString, nodePort);
if (workerNode == NULL)

View File

@ -237,7 +237,7 @@ SELECT * FROM pg_dist_colocation ORDER BY colocationid;
--------------+------------+-------------------+------------------------
(0 rows)
-- Check that repeated calls to sync_metadata has no side effects
-- Check that repeated calls to start_metadata_sync_to_node has no side effects
\c - - - :master_port
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
start_metadata_sync_to_node
@ -308,6 +308,18 @@ Indexes:
"mx_test_table_col_1_key" UNIQUE CONSTRAINT, btree (col_1)
"mx_index" btree (col_2)
-- Make sure that start_metadata_sync_to_node cannot be called inside a transaction
\c - - - :master_port
BEGIN;
SELECT start_metadata_sync_to_node('localhost', :worker_2_port);
ERROR: start_metadata_sync_to_node cannot run inside a transaction block
ROLLBACK;
SELECT hasmetadata FROM pg_dist_node WHERE nodeport=:worker_2_port;
hasmetadata
-------------
f
(1 row)
-- Cleanup
\c - - - :worker_1_port
DROP TABLE mx_testing_schema.mx_test_table;

View File

@ -80,7 +80,7 @@ SELECT * FROM pg_dist_shard_placement ORDER BY shardid;
-- Check that pg_dist_colocation is not synced
SELECT * FROM pg_dist_colocation ORDER BY colocationid;
-- Check that repeated calls to sync_metadata has no side effects
-- Check that repeated calls to start_metadata_sync_to_node has no side effects
\c - - - :master_port
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
@ -92,6 +92,14 @@ SELECT * FROM pg_dist_shard ORDER BY shardid;
SELECT * FROM pg_dist_shard_placement ORDER BY shardid;
\d mx_testing_schema.mx_test_table
-- Make sure that start_metadata_sync_to_node cannot be called inside a transaction
\c - - - :master_port
BEGIN;
SELECT start_metadata_sync_to_node('localhost', :worker_2_port);
ROLLBACK;
SELECT hasmetadata FROM pg_dist_node WHERE nodeport=:worker_2_port;
-- Cleanup
\c - - - :worker_1_port
DROP TABLE mx_testing_schema.mx_test_table;