[#1812] policer: Do not remove copies if there are maintenance nodes

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-26 17:10:14 +03:00 committed by fyrchik
parent 280e56f4bb
commit 846ff515e6

View file

@ -144,12 +144,18 @@ func (p *Policer) processNodes(ctx *processPlacementContext, addr oid.Address,
nodes []netmap.NodeInfo, shortage uint32, checkedNodes *nodeCache) { nodes []netmap.NodeInfo, shortage uint32, checkedNodes *nodeCache) {
prm := new(headsvc.RemoteHeadPrm).WithObjectAddress(addr) prm := new(headsvc.RemoteHeadPrm).WithObjectAddress(addr)
// Number of copies that are stored on maintenance nodes.
var uncheckedCopies int
handleMaintenance := func(node netmap.NodeInfo) { handleMaintenance := func(node netmap.NodeInfo) {
// consider remote nodes under maintenance as problem OK. Such // consider remote nodes under maintenance as problem OK. Such
// nodes MAY not respond with object, however, this is how we // nodes MAY not respond with object, however, this is how we
// prevent spam with new replicas. // prevent spam with new replicas.
// However, additional copies should not be removed in this case,
// because we can remove the only copy this way.
checkedNodes.submitReplicaHolder(node) checkedNodes.submitReplicaHolder(node)
shortage-- shortage--
uncheckedCopies++
p.log.Debug("consider node under maintenance as OK", p.log.Debug("consider node under maintenance as OK",
zap.String("node", netmap.StringifyPublicKey(node)), zap.String("node", netmap.StringifyPublicKey(node)),
@ -221,6 +227,12 @@ func (p *Policer) processNodes(ctx *processPlacementContext, addr oid.Address,
task.SetCopiesNumber(shortage) task.SetCopiesNumber(shortage)
p.replicator.HandleTask(ctx, task, checkedNodes) p.replicator.HandleTask(ctx, task, checkedNodes)
} else if uncheckedCopies > 0 {
// If we have more copies than needed, but some of them are from the maintenance nodes,
// save the local copy.
ctx.needLocalCopy = true
p.log.Debug("some of the copies are stored on nodes under maintenance, save local copy",
zap.Int("count", uncheckedCopies))
} }
} }