[
https://issues.apache.org/jira/browse/HDDS-17910?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Aleksei Ieshin updated HDDS-17910:
----------------------------------
Description:
h3. Problem
When an EC container needs more replicas than there are racks (for example
rs-10-4 = 14 or rs-6-3 = 9 on 8 racks), {{SCMContainerPlacementRackScatter}}
always puts the extra replicas on the same racks, in the same order, for every
container. Since {{ECPipelineProvider#create}} numbers the chosen nodes 1..n in
the order the policy returns them, the same racks also always receive the same
replica indexes.
h3. Mechanism
{{chooseDatanodesInternal}} picks nodes in two passes:
# First pass: one node per rack. The rack list comes from
{{{}getAllRacks(){}}}, which shuffles it, so the order is random.
# Second pass, only when nodes are still missing: fill racks that already have
a replica, up to {{{}maxReplicasPerRack{}}}.
The second pass builds its rack list like this (master, lines ~335-338):
{code:java}
racks.addAll(usedRacksCntMap.keySet());
racks = sortRackWithExcludedNodes(racks, excludedNodes, usedRacksCntMap);
racks.addAll(usedRacksCntMap.keySet());
{code}
{{sortRackWithExcludedNodes}} keeps only racks that are not in
{{{}usedRacksCntMap{}}}. On a new placement the first pass has used every rack,
so it returns an empty list, and the second pass walks
{{usedRacksCntMap.keySet()}} only. {{usedRacksCntMap}} is a {{HashMap}} keyed
by rack nodes that hash by their path ({{{}NodeImpl#hashCode{}}}
={{{}toString().hashCode(){}}}), so this order is the same for every call and
across SCM restarts.
The shuffle of the first pass is lost.
h3. Fix
Randomise the second-pass rack order while keeping the filtering, which still
matters for repairs (racks without a replica first).
was:
h3. Problem
When an EC container needs more replicas than there are racks (for example
rs-10-4 = 14 or rs-6-3 = 9 on 8 racks), {{SCMContainerPlacementRackScatter}}
always puts the extra replicas on the same racks, in the same order, for every
container. Since {{ECPipelineProvider#create}} numbers the chosen nodes 1..n in
the order the policy returns them, the same racks also always receive the same
replica indexes.
h3. Mechanism
{{chooseDatanodesInternal}} picks nodes in two passes:
# First pass: one node per rack. The rack list comes from
{{{}getAllRacks(){}}}, which shuffles it, so the order is random.
# Second pass, only when nodes are still missing: fill racks that already have
a replica, up to {{{}maxReplicasPerRack{}}}.
The second pass builds its rack list like this (master, lines ~335-338):
{code:java}
racks.addAll(usedRacksCntMap.keySet());
racks = sortRackWithExcludedNodes(racks, excludedNodes, usedRacksCntMap);
racks.addAll(usedRacksCntMap.keySet());
{code}
{{sortRackWithExcludedNodes}} keeps only racks that are not in
{{{}usedRacksCntMap{}}}. On a new placement the first pass has used every rack,
so it returns an empty list, and the second pass walks
{{usedRacksCntMap.keySet()}} only. {{usedRacksCntMap}} is a {{HashMap}} keyed
by rack nodes that hash by their path ({{{}NodeImpl#hashCode{}}}
={{{}toString().hashCode(){}}}), so this order is the same for every call and
across SCM restarts.
The shuffle of the first pass is lost.
h3. Fix
Randomise the second-pass rack order while keeping the filtering, which still
matters for repairs (racks without a replica first). For example, add the used
racks in random order:
\{code:java}
List<Node> usedRacks = new ArrayList<>(usedRacksCntMap.keySet());
Collections.shuffle(usedRacks);
racks.addAll(usedRacks);
racks = sortRackWithExcludedNodes(racks, excludedNodes, usedRacksCntMap);
racks.addAll(usedRacks);
\{code}
> RackScatter fills extra EC replicas into racks in a fixed order, so the same
> racks always hold the same EC indexes when width > rack count
> ------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HDDS-17910
> URL: https://issues.apache.org/jira/browse/HDDS-17910
> Project: Apache Ozone
> Issue Type: Bug
> Components: SCM
> Reporter: Aleksei Ieshin
> Priority: Major
>
> h3. Problem
> When an EC container needs more replicas than there are racks (for example
> rs-10-4 = 14 or rs-6-3 = 9 on 8 racks), {{SCMContainerPlacementRackScatter}}
> always puts the extra replicas on the same racks, in the same order, for
> every container. Since {{ECPipelineProvider#create}} numbers the chosen nodes
> 1..n in the order the policy returns them, the same racks also always receive
> the same replica indexes.
> h3. Mechanism
> {{chooseDatanodesInternal}} picks nodes in two passes:
> # First pass: one node per rack. The rack list comes from
> {{{}getAllRacks(){}}}, which shuffles it, so the order is random.
> # Second pass, only when nodes are still missing: fill racks that already
> have a replica, up to {{{}maxReplicasPerRack{}}}.
> The second pass builds its rack list like this (master, lines ~335-338):
> {code:java}
> racks.addAll(usedRacksCntMap.keySet());
> racks = sortRackWithExcludedNodes(racks, excludedNodes, usedRacksCntMap);
> racks.addAll(usedRacksCntMap.keySet());
> {code}
> {{sortRackWithExcludedNodes}} keeps only racks that are not in
> {{{}usedRacksCntMap{}}}. On a new placement the first pass has used every
> rack, so it returns an empty list, and the second pass walks
> {{usedRacksCntMap.keySet()}} only. {{usedRacksCntMap}} is a {{HashMap}} keyed
> by rack nodes that hash by their path ({{{}NodeImpl#hashCode{}}}
> ={{{}toString().hashCode(){}}}), so this order is the same for every call and
> across SCM restarts.
> The shuffle of the first pass is lost.
>
> h3. Fix
>
>
>
>
>
> Randomise the second-pass rack order while keeping the filtering, which still
> matters for repairs (racks without a replica first).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]