Skip to content

primary weight factor should exchange primary and replica at the same in the smalll cluster in some case #8060

@kkewwei

Description

@kkewwei

Is your feature request related to a problem? Please describe.
It is very much looking forward to introducing the primary weight factor in #6017, but it seems not work in the small cluster, for example:
index1 settings:

 "number_of_replicas": "2",
 "number_of_shards": "3"

The cluster has three nodes: node0, node1, node2, the allocation of the index1 is:
                node0 node1 node2
shard0           p           r           r
shard1           p           r           r
shard2           p           r           r
there are 3 primary shards in the node0.

When put the settings:

PUT _cluster/settings
{
    "persistent": {
        "cluster.routing.allocation.balance.prefer_primary":"true"
    }
}

There will no primary rebalance as expected, the reason is that a copy of this shard is already allocated to every target host.

Describe the solution you'd like
There are good reasons to rebalance primary shards. When rebalancing the primary ,and target node has the replica shard, if we should exchange the primary and replica at the same time.

In addition, I'm a little confused why we not Introduce cluster.primary.shard.balance.constraint in rebalance, the feature seems usefully in certain scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions