mirror of https://github.com/citusdata/citus.git
Allow create_distributed_table_concurrently on an empty node (#6353)
Co-authored-by: Marco Slot <marco.slot@gmail.com>pull/6354/head
parent
57e354ac91
commit
8544346a78
|
@ -128,6 +128,9 @@ citus_add_local_table_to_metadata_internal(Oid relationId, bool cascadeViaForeig
|
|||
{
|
||||
CheckCitusVersion(ERROR);
|
||||
|
||||
/* enable citus_add_local_table_to_metadata on an empty node */
|
||||
InsertCoordinatorIfClusterEmpty();
|
||||
|
||||
bool autoConverted = false;
|
||||
CreateCitusLocalTable(relationId, cascadeViaForeignKeys, autoConverted);
|
||||
}
|
||||
|
|
|
@ -382,7 +382,6 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
|
|||
"citus.shard_replication_factor > 1")));
|
||||
}
|
||||
|
||||
EnsureCoordinatorIsInMetadata();
|
||||
EnsureCitusTableCanBeCreated(relationId);
|
||||
|
||||
EnsureValidDistributionColumn(relationId, distributionColumnName);
|
||||
|
|
|
@ -1521,6 +1521,66 @@ SELECT count(*) FROM pg_stat_activity WHERE application_name = 'Citus Maintenanc
|
|||
1
|
||||
(1 row)
|
||||
|
||||
-- confirm that we can create a distributed table concurrently on an empty node
|
||||
DROP EXTENSION citus;
|
||||
CREATE EXTENSION citus;
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SET citus.defer_drop_after_shard_split TO off;
|
||||
SELECT create_distributed_table_concurrently('test','x');
|
||||
NOTICE: relation test does not have a REPLICA IDENTITY or PRIMARY KEY
|
||||
DETAIL: UPDATE and DELETE commands on the relation will error out during create_distributed_table_concurrently unless there is a REPLICA IDENTITY or PRIMARY KEY. INSERT commands will still work.
|
||||
create_distributed_table_concurrently
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP TABLE test;
|
||||
TRUNCATE pg_dist_node;
|
||||
-- confirm that we can create a distributed table on an empty node
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table('test','x');
|
||||
NOTICE: Copying data from local table...
|
||||
NOTICE: copying the data has completed
|
||||
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.test$$)
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP TABLE test;
|
||||
TRUNCATE pg_dist_node;
|
||||
-- confirm that we can create a reference table on an empty node
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SELECT create_reference_table('test');
|
||||
NOTICE: Copying data from local table...
|
||||
NOTICE: copying the data has completed
|
||||
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.test$$)
|
||||
create_reference_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP TABLE test;
|
||||
TRUNCATE pg_dist_node;
|
||||
-- confirm that we can create a local table on an empty node
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SELECT citus_add_local_table_to_metadata('test');
|
||||
citus_add_local_table_to_metadata
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP TABLE test;
|
||||
DROP EXTENSION citus;
|
||||
CREATE EXTENSION citus;
|
||||
DROP TABLE version_mismatch_table;
|
||||
DROP SCHEMA multi_extension;
|
||||
ERROR: cannot drop schema multi_extension because other objects depend on it
|
||||
|
|
|
@ -795,5 +795,39 @@ FROM test.maintenance_worker();
|
|||
-- confirm that there is only one maintenance daemon
|
||||
SELECT count(*) FROM pg_stat_activity WHERE application_name = 'Citus Maintenance Daemon';
|
||||
|
||||
-- confirm that we can create a distributed table concurrently on an empty node
|
||||
DROP EXTENSION citus;
|
||||
CREATE EXTENSION citus;
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SET citus.defer_drop_after_shard_split TO off;
|
||||
SELECT create_distributed_table_concurrently('test','x');
|
||||
DROP TABLE test;
|
||||
TRUNCATE pg_dist_node;
|
||||
|
||||
-- confirm that we can create a distributed table on an empty node
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table('test','x');
|
||||
DROP TABLE test;
|
||||
TRUNCATE pg_dist_node;
|
||||
|
||||
-- confirm that we can create a reference table on an empty node
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SELECT create_reference_table('test');
|
||||
DROP TABLE test;
|
||||
TRUNCATE pg_dist_node;
|
||||
|
||||
-- confirm that we can create a local table on an empty node
|
||||
CREATE TABLE test (x int, y int);
|
||||
INSERT INTO test VALUES (1,2);
|
||||
SELECT citus_add_local_table_to_metadata('test');
|
||||
DROP TABLE test;
|
||||
DROP EXTENSION citus;
|
||||
CREATE EXTENSION citus;
|
||||
|
||||
DROP TABLE version_mismatch_table;
|
||||
DROP SCHEMA multi_extension;
|
||||
|
|
Loading…
Reference in New Issue