mirror of https://github.com/citusdata/citus.git
Do not rebalance if replication factor is greater than the node count
parent
c2f46f0f3f
commit
c968dc9c27
|
@ -526,6 +526,13 @@ GetRebalanceSteps(RebalanceOptions *options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shardAllowedNodeCount < ShardReplicationFactor)
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errmsg("Shard replication factor (%d) cannot be greater than "
|
||||||
|
"number of nodes with should_have_shards=true (%d).",
|
||||||
|
ShardReplicationFactor, shardAllowedNodeCount)));
|
||||||
|
}
|
||||||
|
|
||||||
List *activeShardPlacementListList = NIL;
|
List *activeShardPlacementListList = NIL;
|
||||||
List *unbalancedShards = NIL;
|
List *unbalancedShards = NIL;
|
||||||
|
|
||||||
|
|
|
@ -2553,12 +2553,18 @@ SELECT public.wait_until_metadata_sync(30000);
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- errors out because shard replication factor > shard allowed node count
|
||||||
|
SELECT rebalance_table_shards('test_rebalance_with_disabled_worker');
|
||||||
|
ERROR: Shard replication factor (2) cannot be greater than number of nodes with should_have_shards=true (1).
|
||||||
|
-- set replication factor to one, and try again
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
SELECT rebalance_table_shards('test_rebalance_with_disabled_worker');
|
SELECT rebalance_table_shards('test_rebalance_with_disabled_worker');
|
||||||
rebalance_table_shards
|
rebalance_table_shards
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET citus.shard_replication_factor TO 2;
|
||||||
SELECT 1 FROM citus_activate_node('localhost', :worker_2_port);
|
SELECT 1 FROM citus_activate_node('localhost', :worker_2_port);
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
|
@ -411,6 +411,7 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM single_nod
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
NOTICE: issuing ROLLBACK
|
NOTICE: issuing ROLLBACK
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
-- now, lets move all the shards of distributed tables out of the coordinator
|
-- now, lets move all the shards of distributed tables out of the coordinator
|
||||||
-- block writes is much faster for the sake of the test timings we prefer it
|
-- block writes is much faster for the sake of the test timings we prefer it
|
||||||
SELECT master_drain_node('localhost', :master_port, shard_transfer_mode:='block_writes');
|
SELECT master_drain_node('localhost', :master_port, shard_transfer_mode:='block_writes');
|
||||||
|
|
|
@ -1427,8 +1427,14 @@ SELECT create_distributed_table('test_rebalance_with_disabled_worker', 'a', colo
|
||||||
SELECT citus_disable_node('localhost', :worker_2_port);
|
SELECT citus_disable_node('localhost', :worker_2_port);
|
||||||
SELECT public.wait_until_metadata_sync(30000);
|
SELECT public.wait_until_metadata_sync(30000);
|
||||||
|
|
||||||
|
-- errors out because shard replication factor > shard allowed node count
|
||||||
SELECT rebalance_table_shards('test_rebalance_with_disabled_worker');
|
SELECT rebalance_table_shards('test_rebalance_with_disabled_worker');
|
||||||
|
|
||||||
|
-- set replication factor to one, and try again
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
SELECT rebalance_table_shards('test_rebalance_with_disabled_worker');
|
||||||
|
SET citus.shard_replication_factor TO 2;
|
||||||
|
|
||||||
SELECT 1 FROM citus_activate_node('localhost', :worker_2_port);
|
SELECT 1 FROM citus_activate_node('localhost', :worker_2_port);
|
||||||
|
|
||||||
DROP TABLE test_rebalance_with_disabled_worker;
|
DROP TABLE test_rebalance_with_disabled_worker;
|
||||||
|
|
|
@ -272,6 +272,8 @@ BEGIN;
|
||||||
SELECT count(*) FROM test;
|
SELECT count(*) FROM test;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
|
||||||
-- now, lets move all the shards of distributed tables out of the coordinator
|
-- now, lets move all the shards of distributed tables out of the coordinator
|
||||||
-- block writes is much faster for the sake of the test timings we prefer it
|
-- block writes is much faster for the sake of the test timings we prefer it
|
||||||
SELECT master_drain_node('localhost', :master_port, shard_transfer_mode:='block_writes');
|
SELECT master_drain_node('localhost', :master_port, shard_transfer_mode:='block_writes');
|
||||||
|
|
Loading…
Reference in New Issue