From 4538ccb12a4769eeb397417f0b755dc1bc7bd712 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 16 Jan 2025 15:59:17 +0300 Subject: [PATCH] [#1604] policer: Do not process the same node twice Signed-off-by: Evgenii Stratonikov --- pkg/services/policer/check.go | 6 +++--- pkg/services/policer/nodecache.go | 1 + pkg/services/policer/policer_test.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index 9335a75d8..f79ffbece 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -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) } } } diff --git a/pkg/services/policer/nodecache.go b/pkg/services/policer/nodecache.go index 7a8217858..84a333278 100644 --- a/pkg/services/policer/nodecache.go +++ b/pkg/services/policer/nodecache.go @@ -8,6 +8,7 @@ const ( nodeNotProcessed nodeProcessStatus = iota nodeDoesNotHoldObject nodeHoldsObject + nodeStatusUnknown ) func (st nodeProcessStatus) Processed() bool { diff --git a/pkg/services/policer/policer_test.go b/pkg/services/policer/policer_test.go index 4e17e98a8..2ed71c404 100644 --- a/pkg/services/policer/policer_test.go +++ b/pkg/services/policer/policer_test.go @@ -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",