forked from TrueCloudLab/frostfs-node
[#884] shard: Mark expired tombstones as garbage
Mark expired tombstones as garbage in `Shard.HandleExpiredTombstones`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
8efeba8010
commit
1b3637aad7
1 changed files with 52 additions and 9 deletions
|
@ -294,13 +294,16 @@ func (s *Shard) collectExpiredTombstones(ctx context.Context, e Event) {
|
|||
s.expiredTombstonesCallback(ctx, expired)
|
||||
}
|
||||
|
||||
// HandleExpiredTombstones mark to be removed all objects that are expired in epoch
|
||||
// and protected by tombstone with string address from tss.
|
||||
// HandleExpiredTombstones marks to be removed all objects that are
|
||||
// protected by tombstones with string addresses from tss.
|
||||
// If successful, marks tombstones themselves as garbage.
|
||||
//
|
||||
// Does not modify tss.
|
||||
func (s *Shard) HandleExpiredTombstones(tss map[string]struct{}) {
|
||||
inhume := make([]*object.Address, 0, len(tss))
|
||||
|
||||
// Collect all objects covered by the tombstones.
|
||||
|
||||
err := s.metaBase.IterateCoveredByTombstones(tss, func(addr *object.Address) error {
|
||||
inhume = append(inhume, addr)
|
||||
return nil
|
||||
|
@ -310,15 +313,20 @@ func (s *Shard) HandleExpiredTombstones(tss map[string]struct{}) {
|
|||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
return
|
||||
} else if len(inhume) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = s.metaBase.Inhume(new(meta.InhumePrm).
|
||||
WithAddresses(inhume...).
|
||||
WithGCMark(),
|
||||
)
|
||||
// Mark collected objects as garbage.
|
||||
|
||||
var pInhume meta.InhumePrm
|
||||
|
||||
pInhume.WithGCMark()
|
||||
|
||||
if len(inhume) > 0 {
|
||||
// inhume objects
|
||||
pInhume.WithAddresses(inhume...)
|
||||
|
||||
_, err = s.metaBase.Inhume(&pInhume)
|
||||
if err != nil {
|
||||
s.log.Warn("could not inhume objects under the expired tombstone",
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -327,3 +335,38 @@ func (s *Shard) HandleExpiredTombstones(tss map[string]struct{}) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the tombstones as garbage.
|
||||
|
||||
inhume = inhume[:0]
|
||||
|
||||
for strAddr := range tss {
|
||||
// parse address
|
||||
// TODO: make type of map values *object.Address since keys are calculated from addresses
|
||||
addr := object.NewAddress()
|
||||
|
||||
err = addr.Parse(strAddr)
|
||||
if err != nil {
|
||||
s.log.Error("could not parse tombstone address",
|
||||
zap.String("text", strAddr),
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
continue // try process other tombstones
|
||||
}
|
||||
|
||||
inhume = append(inhume, addr)
|
||||
}
|
||||
|
||||
pInhume.WithAddresses(inhume...) // GC mark is already set above
|
||||
|
||||
// inhume tombstones
|
||||
_, err = s.metaBase.Inhume(&pInhume)
|
||||
if err != nil {
|
||||
s.log.Warn("could not mark tombstones as garbage",
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue