refactor(meta): hybrid cloud optimize meta log in UpdateExtentKeyAfterMigration()

#22395995
Signed-off-by: true1064 <tangjingyu@oppo.com>
This commit is contained in:
true1064 2024-07-30 19:30:45 +08:00 committed by AmazingChi
parent 7346d24e74
commit 42aaa6d19a
3 changed files with 28 additions and 22 deletions

View File

@ -1137,11 +1137,11 @@ func (mp *metaPartition) fsmUpdateExtentKeyAfterMigration(inoParam *Inode) (resp
i.HybridCouldExtents.sortedEks = inoParam.HybridCouldExtentsMigration.sortedEks
// delete migration ek in future
i.Flag |= DeleteMigrationExtentKeyFlag
log.LogInfof("action[fsmUpdateExtentKeyAfterMigration] mp(%v) inode %v storage class change from %v to %v", i.Inode,
mp.config.PartitionId, i.HybridCouldExtentsMigration.storageClass, i.StorageClass)
log.LogInfof("action[fsmUpdateExtentKeyAfterMigration] mp(%v) inode(%v) storage class change from %v to %v",
mp.config.PartitionId, i.Inode, i.HybridCouldExtentsMigration.storageClass, i.StorageClass)
logCurrentExtentKeys(i.StorageClass, i.HybridCouldExtents.sortedEks, i.Inode)
logCurrentExtentKeys(i.HybridCouldExtentsMigration.storageClass, i.HybridCouldExtentsMigration.sortedEks, i.Inode)
log.LogInfof("action[fsmUpdateExtentKeyAfterMigration] mp(%v) inode %v migration ek will be deleted at %v",
log.LogInfof("action[fsmUpdateExtentKeyAfterMigration] mp(%v) inode(%v) migration ek will be deleted at %v",
mp.config.PartitionId, i.Inode, time.Unix(i.HybridCouldExtentsMigration.expiredTime, 0).Format("2006-01-02 15:04:05"))
mp.freeList.Push(i.Inode)
return
@ -1193,7 +1193,7 @@ func (mp *metaPartition) internalDeleteMigrationExtentKey(val []byte) (err error
}
return
}
log.LogDebugf("internalDeleteMigrationExtentKey: partitionID(%v) inode(%v)",
log.LogDebugf("internalDeleteMigrationExtentKey: partitionID(%v) inode(%v)",
mp.config.PartitionId, inoParam.Inode)
err = mp.internalDeleteInodeMigrationExtentKey(inoParam)
if err != nil {
@ -1216,7 +1216,7 @@ func (mp *metaPartition) internalDeleteInodeMigrationExtentKey(inoParam *Inode)
ino.HybridCouldExtentsMigration.sortedEks = nil
// reset DeleteMigrationExtentKeyFlag for future deletion of inode
ino.Flag ^= DeleteMigrationExtentKeyFlag
log.LogDebugf("internalDeleteInodeMigrationExtentKey: partitionID(%v) inode(%v)",
log.LogDebugf("internalDeleteInodeMigrationExtentKey: partitionID(%v) inode(%v)",
mp.config.PartitionId, inoParam.Inode)
return
}

View File

@ -1153,19 +1153,21 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
}
defer func() {
// delete migration extent key if encounter an error
if err != nil {
delMigrationIno := item.(*Inode)
// prepare HybridCouldExtentsMigration info for extent key delete
if req.StorageClass == proto.StorageClass_BlobStore {
log.LogInfof("action[UpdateExtentKeyAfterMigration] mp(%v) after err, prepare to delete migration obj extent key for inode %v",
mp.config.PartitionId, delMigrationIno.Inode)
delMigrationIno.HybridCouldExtentsMigration.storageClass = req.StorageClass
delMigrationIno.HybridCouldExtentsMigration.sortedEks = NewSortedObjExtentsFromObjEks(req.NewObjExtentKeys)
}
// notify follower to delete migration extent key
mp.internalNotifyFollowerToDeleteExtentKey(delMigrationIno)
if err == nil {
return
}
// delete migration extent key if encounter an error
delMigrationIno := item.(*Inode)
// prepare HybridCouldExtentsMigration info for extent key delete
if req.StorageClass == proto.StorageClass_BlobStore {
log.LogInfof("action[UpdateExtentKeyAfterMigration] mp(%v) after err, prepare to delete migration obj extent key for inode %v",
mp.config.PartitionId, delMigrationIno.Inode)
delMigrationIno.HybridCouldExtentsMigration.storageClass = req.StorageClass
delMigrationIno.HybridCouldExtentsMigration.sortedEks = NewSortedObjExtentsFromObjEks(req.NewObjExtentKeys)
}
// notify follower to delete migration extent key
mp.internalNotifyFollowerToDeleteExtentKey(delMigrationIno)
}()
if atomic.LoadUint32(&ino.ForbiddenMigration) == ForbiddenToMigration {
@ -1195,8 +1197,10 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
ino.HybridCouldExtentsMigration.sortedEks = NewSortedExtents()
} else {
if item.(*Inode).HybridCouldExtentsMigration.storageClass != proto.StorageClass_Replica_HDD {
err = fmt.Errorf("mp(%v) inode(%v) migration storageClass not match, curent(%v), request(%v)",
mp.config.PartitionId, ino.Inode, item.(*Inode).HybridCouldExtentsMigration.storageClass, proto.StorageClass_Replica_HDD)
err = fmt.Errorf("mp(%v) inode(%v) storageClass(%v): migration storageClass is %v, now can not migrate to %v",
mp.config.PartitionId, ino.Inode, proto.StorageClassString(ino.StorageClass),
proto.StorageClassString(item.(*Inode).HybridCouldExtentsMigration.storageClass),
proto.StorageClassString(proto.StorageClass_Replica_HDD))
log.LogErrorf("action[UpdateExtentKeyAfterMigration] %v", err)
p.PacketErrorWithBody(proto.OpArgMismatchErr, []byte(err.Error()))
return
@ -1221,13 +1225,13 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
fsmResp, submitErr := mp.submit(opFSMUpdateExtentKeyAfterMigration, val)
if submitErr != nil {
if submitErr == raft.ErrNotLeader {
err = fmt.Errorf("mp(%v) inode(%v) submit resp not leader", mp.config.PartitionId, ino.Inode)
err = fmt.Errorf("mp(%v) inode(%v), not leader when submit raft", mp.config.PartitionId, ino.Inode)
log.LogErrorf("action[UpdateExtentKeyAfterMigration] %v", err.Error())
p.PacketErrorWithBody(proto.OpAgain, []byte(err.Error()))
return
}
err = fmt.Errorf("mp(%v) inode(%v) submit inner err: %v",
err = fmt.Errorf("mp(%v) inode(%v) submit raft inner err: %v",
mp.config.PartitionId, ino.Inode, err.Error())
log.LogErrorf("action[UpdateExtentKeyAfterMigration] %v", err.Error())
p.PacketErrorWithBody(proto.OpErr, []byte(err.Error()))
@ -1235,7 +1239,7 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
}
fsmRespStatus := fsmResp.(*InodeResponse).Status
if fsmRespStatus != proto.OpOk {
err = fmt.Errorf("mp(%v) inode(%v) storageClass(%v) inner fsm resp err status(%v)",
err = fmt.Errorf("mp(%v) inode(%v) storageClass(%v), raft resp inner err status(%v)",
mp.config.PartitionId, ino.Inode, ino.StorageClass, fsmRespStatus)
log.LogErrorf("action[UpdateExtentKeyAfterMigration] req(%v), err: %v", req, err.Error())
p.PacketErrorWithBody(fsmRespStatus, []byte(err.Error()))

View File

@ -651,6 +651,8 @@ func (p *Packet) GetOpMsg() (m string) {
m = "OpBatchLockNormalExtent"
case OpBatchUnlockNormalExtent:
m = "OpBatchUnlockNormalExtent"
case OpMetaRenewalForbiddenMigration:
m = "OpMetaRenewalForbiddenMigration"
case OpMetaUpdateExtentKeyAfterMigration:
m = "OpMetaUpdateExtentKeyAfterMigration"
case OpDeleteMigrationExtentKey: