While building a script to shrink the number of shards of all partitions of a table, on a multi-node cluster, when changing the allocation of shards to a specific node by running:
ALTER TABLE <table_name>
PARTITION (edate = <partition_to_change>)
SET ("routing.allocation.require._name" = <node_allocate_shards>, "blocks.write" = true);
I get the following explanation: cannot rebalance as no target node exists that can both allocate this shard and improve the cluster balance
and the following decision: the shard cannot be allocated to the same node on which a copy of the shard already exists cratedb
The SHOW CREATE TABLE
output is:
CREATE TABLE IF NOT EXISTS "my_schema"."table1" (
"timestamp" TIMESTAMP WITH TIME ZONE,
"edate" TIMESTAMP WITH TIME ZONE GENERATED ALWAYS AS date_trunc('week', "timestamp"),
)
CLUSTERED INTO 6 SHARDS
PARTITIONED BY ("edate")
WITH (
"allocation.max_retries" = 5,
"blocks.metadata" = false,
"blocks.read" = false,
"blocks.read_only" = false,
"blocks.read_only_allow_delete" = false,
"blocks.write" = false,
codec = 'default',
column_policy = 'dynamic',
"mapping.total_fields.limit" = 1000,
max_ngram_diff = 1,
max_shingle_diff = 3,
number_of_replicas = '0-1',
"routing.allocation.enable" = 'all',
"routing.allocation.total_shards_per_node" = -1,
"store.type" = 'fs',
"translog.durability" = 'REQUEST',
"translog.flush_threshold_size" = 536870912,
"translog.sync_interval" = 5000,
"unassigned.node_left.delayed_timeout" = 60000,
"write.wait_for_active_shards" = '1'
)
This happens with 4 or 2 data nodes in the cluster.
Couldn’t find a solution for this, can anyone point me in the right direction? I can provide more info if needed.