[#1604] policer: Do not process the same node twice

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2025-01-16 15:59:17 +03:00
parent 84e1599997
commit 4538ccb12a
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg
3 changed files with 5 additions and 4 deletions

View file

@ -126,12 +126,11 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
} else {
if status := checkedNodes.processStatus(nodes[i]); status.Processed() {
if status == nodeHoldsObject {
// node already contains replica, no need to replicate
nodes = append(nodes[:i], nodes[i+1:]...)
i--
shortage--
}
nodes = append(nodes[:i], nodes[i+1:]...)
i--
continue
}
@ -155,6 +154,7 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
zap.Stringer("object", addr),
zap.Error(err),
)
checkedNodes.set(nodes[i], nodeStatusUnknown)
}
}
}

View file

@ -8,6 +8,7 @@ const (
nodeNotProcessed nodeProcessStatus = iota
nodeDoesNotHoldObject
nodeHoldsObject
nodeStatusUnknown
)
func (st nodeProcessStatus) Processed() bool {

View file

@ -127,7 +127,7 @@ func TestProcessObject(t *testing.T) {
nodeCount: 2,
policy: `REP 2 REP 2`,
placement: [][]int{{0, 1}, {0, 1}},
wantReplicateTo: []int{1, 1}, // is this actually good?
wantReplicateTo: []int{1},
},
{
desc: "lock object must be replicated to all nodes",