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:
zhumingze 2025-07-23 15:48:50 +08:00 committed by 常亮
parent 69d75fee82
commit 6c244dcf69
2 changed files with 13 additions and 3 deletions

View File

@ -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)

View File

@ -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)