refactor(master): use IsDeleted for volume status checks.

close:#1000542120

Signed-off-by: Victor1319 <zengxuewei@oppo.com>
(cherry picked from commit 0ad5c80c05)
This commit is contained in:
Victor1319 2025-12-12 10:44:56 +08:00 committed by chihe
parent 57321ed6b5
commit d8638e22b5
4 changed files with 11 additions and 8 deletions

View File

@ -1553,17 +1553,16 @@ func (c *Cluster) checkReplicaOfDataPartitions(ignoreDiscardDp bool) (
vols := c.copyVols()
for _, vol := range vols {
if vol.IsDeleted() {
continue
}
dps := vol.dataPartitions
for _, dp := range dps.partitions {
if ignoreDiscardDp && dp.IsDiscard {
continue
}
if (vol.Status == proto.VolStatusMarkDelete && !vol.Forbidden) ||
(vol.Status == proto.VolStatusMarkDelete && vol.Forbidden && time.Until(vol.DeleteExecTime) <= 0) {
continue
}
if proto.IsHot(vol.VolType) {
if dp.lostLeader(c) {
noLeaderDPs = append(noLeaderDPs, dp)

View File

@ -297,7 +297,7 @@ func (c *Cluster) checkReplicaMetaPartitions() (
markDeleteVolNames := make(VolNameSet)
vols := c.copyVols()
for _, vol := range vols {
if vol.Status == proto.VolStatusMarkDelete {
if vol.IsDeleted() {
markDeleteVolNames[vol.Name] = struct{}{}
continue
}
@ -354,7 +354,7 @@ func (c *Cluster) checkReplicaMetaPartitionsV1() (diagnosis *proto.MetaPartition
markDeleteVolNames := make(VolNameSet)
vols := c.copyVols()
for _, vol := range vols {
if vol.Status == proto.VolStatusMarkDelete {
if vol.IsDeleted() {
markDeleteVolNames[vol.Name] = struct{}{}
continue
}

View File

@ -671,7 +671,7 @@ func (mm *monitorMetrics) setMpAndDpMetrics() {
vols := mm.cluster.copyVols()
for _, vol := range vols {
if (vol.Status == proto.VolStatusMarkDelete && !vol.Forbidden) || (vol.Status == proto.VolStatusMarkDelete && vol.Forbidden && vol.DeleteExecTime.Before(time.Now())) {
if vol.IsDeleted() {
continue
}

View File

@ -447,6 +447,10 @@ func (mpsLock *mpsLockManager) CheckExceptionLock(interval time.Duration, expire
}
}
func (vol *Vol) IsDeleted() bool {
return (vol.Status == proto.VolStatusMarkDelete && !vol.Forbidden) || (vol.Status == proto.VolStatusMarkDelete && vol.Forbidden && vol.DeleteExecTime.Before(time.Now()))
}
func (vol *Vol) CheckStrategy(c *Cluster) {
// make sure resume all the processing ver deleting tasks before checking
if !atomic.CompareAndSwapInt32(&vol.VersionMgr.checkStrategy, 0, 1) {