diff --git a/pkg/blob/local/localstorage.go b/pkg/blob/local/localstorage.go index 2c481ab6d..067df3f62 100644 --- a/pkg/blob/local/localstorage.go +++ b/pkg/blob/local/localstorage.go @@ -164,9 +164,18 @@ func SetBlobAsInUse(fName string) error { } /* -Returns if the file exists in the local SegSetKeys struct +Returns true if the file is on disk or in the local SegSetKeys struct */ func IsFilePresentOnLocal(fName string) bool { + _, err := os.Stat(fName) + if err == nil { + return true + } + if !os.IsNotExist(err) { + // We're not sure if we have the file, so don't early exit. + log.Errorf("IsFilePresentOnLocal: Error checking file %s: %v", fName, err) + } + segSetKeysLock.Lock() defer segSetKeysLock.Unlock() if _, exists := segSetKeys[fName]; exists { diff --git a/pkg/segment/reader/segread/segstatsreader.go b/pkg/segment/reader/segread/segstatsreader.go index d9aa5530c..6d6561f89 100644 --- a/pkg/segment/reader/segread/segstatsreader.go +++ b/pkg/segment/reader/segread/segstatsreader.go @@ -26,7 +26,6 @@ import ( "github.com/siglens/siglens/pkg/blob" "github.com/siglens/siglens/pkg/segment/structs" "github.com/siglens/siglens/pkg/segment/utils" - toputils "github.com/siglens/siglens/pkg/utils" log "github.com/sirupsen/logrus" ) @@ -54,6 +53,10 @@ func ReadSegStats(segkey string, qid uint64) (map[string]*structs.SegStats, erro } }() + if len(fdata) == 0 { + return nil, toputils.TeeErrorf("qid=%d, ReadSegStats: empty sst file: %v", qid, fName) + } + rIdx := uint32(0) // version