mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(meta): to avoid write EXTENT_DEL_V2_xx header twice. #22860885
Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
parent
14a53f9143
commit
0a7b6fda95
@ -20,6 +20,7 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
@ -58,9 +59,21 @@ func (mp *metaPartition) createExtentDeleteFile(prefix string, idx int64, fileLi
|
||||
log.LogErrorf("[metaPartition] createExtentDeletFile openFile %v %v error %v", mp.config.RootDir, fileName, err)
|
||||
return
|
||||
}
|
||||
if _, err = fp.Write(extentsFileHeader); err != nil {
|
||||
log.LogErrorf("[metaPartition] createExtentDeletFile Write %v %v error %v", mp.config.RootDir, fileName, err)
|
||||
fp.Close()
|
||||
|
||||
var info fs.FileInfo
|
||||
info, err = fp.Stat()
|
||||
if err != nil {
|
||||
log.LogErrorf("createExtentDeleteFile: stat new file failed, dir %s, name %s, err %v", mp.config.RootDir, fileName, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if info.Size() > 0 {
|
||||
log.LogWarnf("createExtentDeleteFile: file are already exist, no need to write header again, dir %s, name %s, size %d", mp.config.RootDir, fileName, info.Size())
|
||||
} else {
|
||||
if _, err = fp.Write(extentsFileHeader); err != nil {
|
||||
log.LogErrorf("[metaPartition] createExtentDeletFile Write %v %v error %v", mp.config.RootDir, fileName, err)
|
||||
fp.Close()
|
||||
}
|
||||
}
|
||||
fileSize = int64(len(extentsFileHeader))
|
||||
fileList.PushBack(fileName)
|
||||
|
||||
@ -884,7 +884,7 @@ func (mp *metaPartition) fsmSendToChan(val []byte, v3 bool) (status uint8) {
|
||||
panic(fmt.Errorf("[fsmDelExtents] unmarshal sortExtents error, mp[%v], err(%s)", mp.config.PartitionId, err.Error()))
|
||||
}
|
||||
|
||||
log.LogInfof("fsmDelExtents mp[%v] delExtents(%v)", mp.config.PartitionId, len(sortExtents.eks))
|
||||
log.LogWarnf("fsmDelExtents mp[%v] delExtents(%v)", mp.config.PartitionId, len(sortExtents.eks))
|
||||
mp.extDelCh <- sortExtents.eks
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user