Skip to content

Commit

Permalink
Fix bugs reading and checking for certain files (siglens#1667)
Browse files Browse the repository at this point in the history
* Fix checking for a file

* Avoid panic reading empty sst file
  • Loading branch information
AndrewHess authored Sep 21, 2024
1 parent c71f01e commit f15b29d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pkg/blob/local/localstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion pkg/segment/reader/segread/segstatsreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f15b29d

Please sign in to comment.