feat(data): Support asynchronous deletion of expired partition lists.

Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
Victor1319 2024-04-01 15:26:53 +08:00 committed by longerfly
parent f7f012de3d
commit b3f3278e5a

View File

@ -689,21 +689,15 @@ func (d *Disk) RestorePartition(visitor PartitionVisitor, allowDelay bool) (err
close(loadCh)
if len(toDeleteExpiredPartitionNames) > 0 {
log.LogInfof("action[RestorePartition] expiredPartitions %v, disk %v", toDeleteExpiredPartitionNames, d.Path)
go func(toDeleteExpiredPartitions []string) {
log.LogInfof("action[RestorePartition] expiredPartitions %v, disk %v", toDeleteExpiredPartitionNames, d.Path)
notDeletedExpiredPartitionNames := d.deleteExpiredPartitions(toDeleteExpiredPartitionNames)
notDeletedExpiredPartitionNames := d.deleteExpiredPartitions(toDeleteExpiredPartitionNames)
if len(notDeletedExpiredPartitionNames) > 0 {
go func(toDeleteExpiredPartitions []string) {
ticker := time.NewTicker(ExpiredPartitionExistTime)
log.LogInfof("action[RestorePartition] delete expiredPartitions automatically start, toDeleteExpiredPartitions %v", toDeleteExpiredPartitions)
<-ticker.C
d.deleteExpiredPartitions(toDeleteExpiredPartitionNames)
ticker.Stop()
log.LogInfof("action[RestorePartition] delete expiredPartitions automatically finish")
}(notDeletedExpiredPartitionNames)
}
time.Sleep(ExpiredPartitionExistTime)
log.LogInfof("action[RestorePartition] delete expiredPartitions automatically start, toDeleteExpiredPartitions %v", notDeletedExpiredPartitionNames)
d.deleteExpiredPartitions(notDeletedExpiredPartitionNames)
log.LogInfof("action[RestorePartition] delete expiredPartitions automatically finish")
}(toDeleteExpiredPartitionNames)
}
wg.Wait()
return err
@ -732,6 +726,7 @@ func (d *Disk) deleteExpiredPartitions(toDeleteExpiredPartitionNames []string) (
continue
}
log.LogInfof("action[deleteExpiredPartitions] delete expiredPartition %v automatically", partitionName)
time.Sleep(time.Second)
} else {
notDeletedExpiredPartitionNames = append(notDeletedExpiredPartitionNames, partitionName)
}