未验证 提交 b7c0d12d 编写于 作者: W wayblink 提交者: GitHub

Skip file with prefix '.' may exist in filesystem (#22138)

Signed-off-by: Nwayblink <anyang.wang@zilliz.com>
上级 27296a02
......@@ -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)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册