diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 1996bfcc4..f63bcdc4b 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -29,3 +29,4 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi - [crypto/merkle] [\#2756](https://github.com/tendermint/tendermint/issues/2756) Fix crypto/merkle ProofOperators.Verify to check bounds on keypath parts. - [mempool] fix a bug where we create a WAL despite `wal_dir` being empty - [p2p] \#2771 Fix `peer-id` label name in prometheus metrics +- [autofile] [\#2703] do not panic when checking Head size diff --git a/libs/autofile/group.go b/libs/autofile/group.go index fcdf0d0dd..1ec6b240d 100644 --- a/libs/autofile/group.go +++ b/libs/autofile/group.go @@ -230,7 +230,8 @@ func (g *Group) checkHeadSizeLimit() { } size, err := g.Head.Size() if err != nil { - panic(err) + g.Logger.Error("Group's head may grow without bound", "head", g.Head.Path, "err", err) + return } if size >= limit { g.RotateFile() @@ -252,11 +253,11 @@ func (g *Group) checkTotalSizeLimit() { } if index == gInfo.MaxIndex { // Special degenerate case, just do nothing. - g.Logger.Info("Group's head may grow without bound", "head", g.Head.Path) + g.Logger.Error("Group's head may grow without bound", "head", g.Head.Path) return } pathToRemove := filePathForIndex(g.Head.Path, index, gInfo.MaxIndex) - fileInfo, err := os.Stat(pathToRemove) + fInfo, err := os.Stat(pathToRemove) if err != nil { g.Logger.Error("Failed to fetch info for file", "file", pathToRemove) continue @@ -266,7 +267,7 @@ func (g *Group) checkTotalSizeLimit() { g.Logger.Error("Failed to remove path", "path", pathToRemove) return } - totalSize -= fileInfo.Size() + totalSize -= fInfo.Size() } }