mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(data): Determine the disk lost based on the DP information on the master and the locally loaded DP information. #1000244723
Signed-off-by: zhumingze <zhumingze@oppo.com>
This commit is contained in:
parent
69d75fee82
commit
6c244dcf69
@ -784,11 +784,13 @@ func (d *Disk) RestorePartition(visitor PartitionVisitor) (err error) {
|
||||
partitionID uint64
|
||||
partitionSize int
|
||||
replicaDiskInfos = make(map[uint64]string)
|
||||
diskPartitionCnt = make(map[string]int)
|
||||
)
|
||||
|
||||
for _, info := range dinfo.PersistenceDataPartitionsWithDiskPath {
|
||||
if _, ok := replicaDiskInfos[info.PartitionId]; !ok {
|
||||
replicaDiskInfos[info.PartitionId] = info.Disk
|
||||
diskPartitionCnt[info.Disk]++
|
||||
}
|
||||
}
|
||||
fileInfoList, err := os.ReadDir(d.Path)
|
||||
@ -804,9 +806,14 @@ func (d *Disk) RestorePartition(visitor PartitionVisitor) (err error) {
|
||||
)
|
||||
begin := time.Now()
|
||||
defer func() {
|
||||
msg := fmt.Sprintf("[RestorePartition] disk(%v) load all dp(%v) using time(%v)", d.Path, dpNum, time.Since(begin))
|
||||
syslog.Print(msg)
|
||||
log.LogInfo(msg)
|
||||
if dpNum == 0 && diskPartitionCnt[d.Path] > 0 {
|
||||
err = fmt.Errorf("disk(%v) is lost", d.Path)
|
||||
syslog.Print(err)
|
||||
} else {
|
||||
msg := fmt.Sprintf("[RestorePartition] disk(%v) load all dp(%v) using time(%v)", d.Path, dpNum, time.Since(begin))
|
||||
syslog.Print(msg)
|
||||
log.LogInfo(msg)
|
||||
}
|
||||
}()
|
||||
loadCh := make(chan dpLoadInfo, d.space.currentLoadDpCount)
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -470,11 +471,13 @@ func (manager *SpaceManager) LoadDisk(path string, reservedSpace, diskRdonlySpac
|
||||
disk, err = NewDisk(path, reservedSpace, diskRdonlySpace, maxErrCnt, manager, diskEnableReadRepairExtentLimit)
|
||||
if err != nil {
|
||||
log.LogErrorf("NewDisk fail err:[%v]", err)
|
||||
os.Remove(filepath.Join(path, DiskStatusFile))
|
||||
return
|
||||
}
|
||||
err = disk.RestorePartition(visitor)
|
||||
if err != nil {
|
||||
log.LogErrorf("RestorePartition fail err:[%v]", err)
|
||||
os.Remove(filepath.Join(path, DiskStatusFile))
|
||||
return
|
||||
}
|
||||
manager.putDisk(disk)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user