[#1445] policer: Make policer remove orphan locks

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-11-08 11:38:57 +03:00
parent ad7e556c27
commit d755b485e5
Signed by: a-savchuk
GPG key ID: 70C0A7FF6F9C4639
4 changed files with 22 additions and 2 deletions

View file

@ -285,8 +285,7 @@ func addPolicer(c *cfg, keyStorage *util.KeyStorage, clientConstructor *cache.Cl
var inhumePrm engine.InhumePrm var inhumePrm engine.InhumePrm
inhumePrm.MarkAsGarbage(addr) inhumePrm.MarkAsGarbage(addr)
_, err := ls.Inhume(ctx, inhumePrm) if _, err := ls.Inhume(ctx, inhumePrm); err != nil {
if err != nil {
c.log.Warn(logs.FrostFSNodeCouldNotInhumeMarkRedundantCopyAsGarbage, c.log.Warn(logs.FrostFSNodeCouldNotInhumeMarkRedundantCopyAsGarbage,
zap.String("error", err.Error()), zap.String("error", err.Error()),
) )
@ -295,6 +294,7 @@ func addPolicer(c *cfg, keyStorage *util.KeyStorage, clientConstructor *cache.Cl
policer.WithPool(c.cfgObject.pool.replication), policer.WithPool(c.cfgObject.pool.replication),
policer.WithMetrics(c.metricsCollector.PolicerMetrics()), policer.WithMetrics(c.metricsCollector.PolicerMetrics()),
policer.WithKeyStorage(keyStorage), policer.WithKeyStorage(keyStorage),
policer.WithRemoveOrphanLocksFunc(ls.RemoveOrphanLocks),
) )
c.workers = append(c.workers, worker{ c.workers = append(c.workers, worker{

View file

@ -50,6 +50,7 @@ const (
PolicerFailureAtObjectSelectForReplication = "failure at object select for replication" PolicerFailureAtObjectSelectForReplication = "failure at object select for replication"
PolicerPoolSubmission = "pool submission" PolicerPoolSubmission = "pool submission"
PolicerUnableToProcessObj = "unable to process object" PolicerUnableToProcessObj = "unable to process object"
PolicerUnableToRemoveOrphanLocks = "unable to remove orphan locks"
ReplicatorFinishWork = "finish work" ReplicatorFinishWork = "finish work"
ReplicatorCouldNotGetObjectFromLocalStorage = "could not get object from local storage" ReplicatorCouldNotGetObjectFromLocalStorage = "could not get object from local storage"
ReplicatorCouldNotReplicateObject = "could not replicate object" ReplicatorCouldNotReplicateObject = "could not replicate object"

View file

@ -51,6 +51,8 @@ type RemoteObjectGetFunc func(context.Context, netmapSDK.NodeInfo, oid.Address)
type LocalObjectGetFunc func(context.Context, oid.Address) (*objectSDK.Object, error) type LocalObjectGetFunc func(context.Context, oid.Address) (*objectSDK.Object, error)
type RemoveOrphanLocksFunc func(context.Context, oid.Address) error
type cfg struct { type cfg struct {
headTimeout time.Duration headTimeout time.Duration
@ -87,6 +89,8 @@ type cfg struct {
localObject LocalObjectGetFunc localObject LocalObjectGetFunc
keyStorage *util.KeyStorage keyStorage *util.KeyStorage
removeOrphanLocksFn RemoveOrphanLocksFunc
} }
func defaultCfg() *cfg { func defaultCfg() *cfg {
@ -212,3 +216,9 @@ func WithKeyStorage(ks *util.KeyStorage) Option {
c.keyStorage = ks c.keyStorage = ks
} }
} }
func WithRemoveOrphanLocksFunc(v RemoveOrphanLocksFunc) Option {
return func(c *cfg) {
c.removeOrphanLocksFn = v
}
}

View file

@ -75,6 +75,15 @@ func (p *Policer) submitPolicerTask(ctx context.Context, addr object.Info, skipM
zap.String("error", err.Error())) zap.String("error", err.Error()))
} }
if addr.IsLocked {
if err := p.removeOrphanLocksFn(ctx, addr.Address); err != nil {
p.log.Warn(logs.PolicerUnableToRemoveOrphanLocks,
zap.Stringer("object", addr.Address),
zap.Error(err),
)
}
}
p.cache.Add(addr.Address, time.Now()) p.cache.Add(addr.Address, time.Now())
p.objsInWork.remove(addr.Address) p.objsInWork.remove(addr.Address)
p.metrics.IncProcessedObjects() p.metrics.IncProcessedObjects()