mirror of https://github.com/milvus-io/milvus.git
Skip file with prefix '.' may exist in filesystem (#22138)
Signed-off-by: wayblink <anyang.wang@zilliz.com>pull/22295/head
parent
27296a023a
commit
b7c0d12d82
|
@ -23,6 +23,7 @@ import (
|
|||
"path"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/milvus-io/milvus-proto/go-api/schemapb"
|
||||
"github.com/milvus-io/milvus/internal/log"
|
||||
|
@ -127,6 +128,12 @@ func (p *BinlogParser) constructSegmentHolders(insertlogRoot string, deltalogRoo
|
|||
log.Info("Binlog parser: list insert logs", zap.Int("logsCount", len(insertlogs)))
|
||||
for _, insertlog := range insertlogs {
|
||||
log.Info("Binlog parser: mapping insert log to segment", zap.String("insertlog", insertlog))
|
||||
filePath := path.Base(insertlog)
|
||||
// skip file with prefix '.', such as .success .DS_Store
|
||||
if strings.HasPrefix(filePath, ".") {
|
||||
log.Debug("file path might not be a real bin log", zap.String("filePath", filePath))
|
||||
continue
|
||||
}
|
||||
fieldPath := path.Dir(insertlog)
|
||||
fieldStrID := path.Base(fieldPath)
|
||||
fieldID, err := strconv.ParseInt(fieldStrID, 10, 64)
|
||||
|
|
|
@ -308,3 +308,37 @@ func Test_BinlogParserParse(t *testing.T) {
|
|||
err = parser.Parse(paths)
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func Test_BinlogParserSkipFlagFile(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
flushFunc := func(fields map[storage.FieldID]storage.FieldData, shardID int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
chunkManager := &MockChunkManager{
|
||||
listErr: errors.New("error"),
|
||||
listResult: make(map[string][]string),
|
||||
}
|
||||
|
||||
parser, err := NewBinlogParser(ctx, sampleSchema(), 2, 1024, chunkManager, flushFunc, nil, 0, math.MaxUint64)
|
||||
assert.NotNil(t, parser)
|
||||
assert.Nil(t, err)
|
||||
|
||||
insertPath := "insertPath"
|
||||
deltaPath := "deltaPath"
|
||||
|
||||
// chunkManager return error
|
||||
holders, err := parser.constructSegmentHolders(insertPath, deltaPath)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, holders)
|
||||
|
||||
// parse field id error(insert log)
|
||||
chunkManager.listErr = nil
|
||||
chunkManager.listResult[insertPath] = []string{
|
||||
"backup/bak1/data/insert_log/435978159196147009/435978159196147010/435978159261483008/0/435978159903735811",
|
||||
"backup/bak1/data/insert_log/435978159196147009/435978159196147010/435978159261483008/.DS_Store",
|
||||
}
|
||||
_, err = parser.constructSegmentHolders(insertPath, deltaPath)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue