From ebf0e7756766afa9323f8aa5f60c09673ca7112e Mon Sep 17 00:00:00 2001 From: Evgenii Guguchkin Date: Fri, 26 Jun 2026 21:31:02 +0300 Subject: [PATCH] feat: add logging for fraction lifecycle and reorder Suicide steps --- frac/remote.go | 14 +++++++------- fracmanager/lifecycle_manager.go | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/frac/remote.go b/frac/remote.go index 9630b8ca..be3bcf65 100644 --- a/frac/remote.go +++ b/frac/remote.go @@ -216,13 +216,6 @@ func (f *Remote) IsIntersecting(from, to seq.MID) bool { } func (f *Remote) Suicide() { - // FIXME(dkharms): We need to rename `.remote` file to `._remote` to commit deletion intent. - // Now, we might have fraction leaks in S3 storage since [Suicide] is not atomic. - util.MustRemoveFileByPath(f.BaseFileName + consts.RemoteFractionSuffix) - - f.docsCache.Release() - f.indexCache.Release() - files := []string{ filepath.Base(f.BaseFileName) + consts.DocsFileSuffix, filepath.Base(f.BaseFileName) + consts.SdocsFileSuffix, @@ -246,6 +239,13 @@ func (f *Remote) Suicide() { } f.skipMaskProvider.RemoveFrac(f.info.Name()) + + // FIXME(dkharms): We need to rename `.remote` file to `._remote` to commit deletion intent. + // Now, we might have fraction leaks in S3 storage since [Suicide] is not atomic. + util.MustRemoveFileByPath(f.BaseFileName + consts.RemoteFractionSuffix) + + f.docsCache.Release() + f.indexCache.Release() } func (f *Remote) String() string { diff --git a/fracmanager/lifecycle_manager.go b/fracmanager/lifecycle_manager.go index e98c5871..1c028cb2 100644 --- a/fracmanager/lifecycle_manager.go +++ b/fracmanager/lifecycle_manager.go @@ -112,11 +112,18 @@ func (lc *lifecycleManager) offloadLocal(ctx context.Context, sizeLimit uint64, if remote == nil { lc.infoCache.Remove(frac.Info().Name()) + } else { + logger.Info("offload local fraction", + zap.String("name", remote.Info().Name()), + zap.Time("created", time.UnixMilli(int64(remote.Info().CreationTime)))) } // free up local resources frac.Destroy() maintenanceTruncateTotal.Add(1) + logger.Info("remove local fraction", + zap.String("name", frac.Info().Name()), + zap.Time("created", time.UnixMilli(int64(frac.Info().CreationTime)))) }) if err != nil { panic(err) // we do not expect error here @@ -186,8 +193,12 @@ func (lc *lifecycleManager) cleanRemote(retention time.Duration, wg *sync.WaitGr for _, remote := range toDelete { go func() { defer wg.Done() - lc.infoCache.Remove(remote.Info().Name()) + info := remote.Info() + lc.infoCache.Remove(info.Name()) remote.Destroy() + logger.Info("remove remote fraction", + zap.String("name", info.Name()), + zap.Time("created", time.UnixMilli(int64(info.CreationTime)))) }() } } @@ -209,9 +220,13 @@ func (lc *lifecycleManager) cleanLocal(sizeLimit uint64, wg *sync.WaitGroup) { for _, frac := range toDelete { go func() { defer wg.Done() - lc.infoCache.Remove(frac.Info().Name()) + info := frac.Info() + lc.infoCache.Remove(info.Name()) frac.Destroy() maintenanceTruncateTotal.Add(1) + logger.Info("remove local fraction", + zap.String("name", info.Name()), + zap.Time("created", time.UnixMilli(int64(info.CreationTime)))) }() } }