mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 18:13:54 +08:00
Fix maybeGC trigger condition
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
This commit is contained in:
@ -174,15 +174,13 @@ func (gc *GC) maybeGC(ctx context.Context, offset uint64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if storage+offset > gc.StorageGC {
|
||||||
if storage+offset > gc.StorageMax {
|
if storage+offset > gc.StorageMax {
|
||||||
err := ErrMaxStorageExceeded
|
log.Warningf("pre-GC: %s", ErrMaxStorageExceeded)
|
||||||
log.Error(err)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if storage+offset > gc.StorageGC {
|
|
||||||
// Do GC here
|
// Do GC here
|
||||||
log.Info("Starting repo GC...")
|
log.Info("Watermark exceeded. Starting repo GC...")
|
||||||
defer log.EventBegin(ctx, "repoGC").Done()
|
defer log.EventBegin(ctx, "repoGC").Done()
|
||||||
// 1 minute is sufficient for ~1GB unlink() blocks each of 100kb in SSD
|
// 1 minute is sufficient for ~1GB unlink() blocks each of 100kb in SSD
|
||||||
_ctx, cancel := context.WithTimeout(ctx, time.Duration(gc.SlackGB)*time.Minute)
|
_ctx, cancel := context.WithTimeout(ctx, time.Duration(gc.SlackGB)*time.Minute)
|
||||||
@ -196,7 +194,14 @@ func (gc *GC) maybeGC(ctx context.Context, offset uint64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Infof("Repo GC done. Released %s\n", humanize.Bytes(uint64(storage-newStorage)))
|
log.Infof("Repo GC done. Released %s\n", humanize.Bytes(uint64(storage-newStorage)))
|
||||||
return nil
|
if newStorage > gc.StorageGC {
|
||||||
|
log.Warningf("post-GC: Watermark still exceeded")
|
||||||
|
if newStorage > gc.StorageMax {
|
||||||
|
err := ErrMaxStorageExceeded
|
||||||
|
log.Error(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user