[#1318] engine: Change tombstone clear process

- Delete objects physically on tombstone's arrival;
- Store information about tombstones in the Graveyard;
- Clear Graveyard every epoch based on the information about TS in the
network.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-04-19 21:00:22 +03:00 committed by LeL
parent e4cfeec449
commit 7799f8e4cf
4 changed files with 93 additions and 66 deletions

View file

@ -25,11 +25,16 @@ type Shard struct {
blobStor *blobstor.BlobStor
metaBase *meta.DB
tsSource TombstoneSource
}
// Option represents Shard's constructor option.
type Option func(*cfg)
// ExpiredTombstonesCallback is a callback handling list of expired tombstones.
type ExpiredTombstonesCallback func(context.Context, []meta.TombstonedObject)
// ExpiredObjectsCallback is a callback handling list of expired objects.
type ExpiredObjectsCallback func(context.Context, []*addressSDK.Address)
@ -54,9 +59,11 @@ type cfg struct {
gcCfg *gcCfg
expiredTombstonesCallback ExpiredObjectsCallback
expiredTombstonesCallback ExpiredTombstonesCallback
expiredLocksCallback ExpiredObjectsCallback
tsSource TombstoneSource
}
func defaultCfg() *cfg {
@ -91,6 +98,7 @@ func New(opts ...Option) *Shard {
blobStor: bs,
metaBase: mb,
writeCache: writeCache,
tsSource: c.tsSource,
}
s.fillInfo()
@ -184,7 +192,7 @@ func WithGCRemoverSleepInterval(dur time.Duration) Option {
// WithExpiredTombstonesCallback returns option to specify callback
// of the expired tombstones handler.
func WithExpiredTombstonesCallback(cb ExpiredObjectsCallback) Option {
func WithExpiredTombstonesCallback(cb ExpiredTombstonesCallback) Option {
return func(c *cfg) {
c.expiredTombstonesCallback = cb
}
@ -214,6 +222,13 @@ func WithMode(v Mode) Option {
}
}
// WithTombstoneSource returns option to set TombstoneSource.
func WithTombstoneSource(v TombstoneSource) Option {
return func(c *cfg) {
c.tsSource = v
}
}
func (s *Shard) fillInfo() {
s.cfg.info.MetaBaseInfo = s.metaBase.DumpInfo()
s.cfg.info.BlobStorInfo = s.blobStor.DumpInfo()