fix(master): add upper and lower limit judgment when setting gogc value

overwrite is been allowed when dp decommission.

close:#1000011090 #1000161090

Signed-off-by: shuqiang-zheng <zhengshuqiang@oppo.com>
This commit is contained in:
shuqiang-zheng 2025-06-05 11:48:50 +08:00 committed by zhumingze1108
parent 94ff433984
commit c8176fc7fc
5 changed files with 5 additions and 62 deletions

View File

@ -876,7 +876,7 @@ func formatTimeToString(t time.Time) string {
return t.Format("2006-01-02 15:04:05")
}
var dataReplicaTableRowPattern = "%-65v %-12v %-12v %-12v %-12v %-12v %-12v %-12v %-18v %-10v"
var dataReplicaTableRowPattern = "%-65v %-12v %-12v %-12v %-12v %-12v %-12v %-12v %-12v %-18v %-10v"
func formatDataReplicaTableHeader() string {
return fmt.Sprintf(dataReplicaTableRowPattern, "ADDR", "USEDSIZE", "TOTALSIZE", "ISLEADER", "FILECOUNT", "HASLOADRESPONSE", "NEEDSTOCOMPARE", "ISREPAIRING", "STATUS", "DISKPATH", "REPORT TIME")

View File

@ -533,7 +533,7 @@ func (partition *DataPartition) fsmSetRepairingStatusOp(opItem *RaftCmdItem) (er
partition.isRepairing = oldStatus
return
}
log.LogInfof("action[fsmSetRepairingStatusOp] %v set repairingStatus %v success", partition.partitionID, req.RepairingStatus)
log.LogWarnf("action[fsmSetRepairingStatusOp] %v set repairingStatus %v success", partition.partitionID, req.RepairingStatus)
return
}

View File

@ -564,7 +564,7 @@ func (s *DataNode) handleHeartbeatPacket(p *repl.Packet) {
_ = json.Unmarshal(marshaled, request)
response.Status = proto.TaskSucceeds
if !s.useLocalGOGC {
if s.gogcValue != request.DataNodeGOGC {
if s.gogcValue != request.DataNodeGOGC && request.DataNodeGOGC >= defaultGOGCLowerLimit && request.DataNodeGOGC <= defaultGOGCUpperLimit {
oldGOGC := s.gogcValue
debug.SetGCPercent(request.DataNodeGOGC)
s.gogcValue = request.DataNodeGOGC
@ -1093,11 +1093,6 @@ func (s *DataNode) handleRandomWritePacket(p *repl.Packet) {
return
}
if partition.isRepairing {
err = storage.DpDecommissionRepairError
return
}
if err = s.checkForbidWriteOpOfProtoVer0(p, partition); err != nil {
return
}
@ -1814,7 +1809,7 @@ func (s *DataNode) handlePacketToSetRepairingStatus(p *repl.Packet) {
}
err = dp.HandleSetRepairingStatusOp(request)
log.LogInfof("action[handlePacketToSetRepairStatus] opcode %v dpid %v after raft submit err %v resultCode %v", p.Opcode, p.PartitionID, err)
log.LogInfof("action[handlePacketToSetRepairStatus] opcode %v dpid %v after raft submit err %v", p.Opcode, p.PartitionID, err)
}
func (s *DataNode) handlePacketToStopDataPartitionRepair(p *repl.Packet) {

View File

@ -124,58 +124,6 @@ func TestSkipAppendWrite(t *testing.T) {
require.EqualValues(t, proto.OpArgMismatchErr, p.ResultCode)
}
func TestDpDecommissionRepairForbidExtentDeleteAndWrite(t *testing.T) {
dn := newDataNodeForOperatorTest(t)
dp := newDpForOperatorTest(t, dn)
extentId := uint64(1000)
p := newPacketForOperatorTest(t, dp, extentId)
p.Opcode = proto.OpCreateExtent
dn.handlePacketToCreateExtent(p)
t.Logf("handle create extent, result code(%v)", p.ResultCode)
require.EqualValues(t, proto.OpOk, p.ResultCode)
t.Run("set repairingStatus true, forbid extent deletion and business writes", func(t *testing.T) {
req := &proto.SetDataPartitionRepairingStatusRequest{PartitionId: dp.partitionID, RepairingStatus: true}
task := &proto.AdminTask{
OpCode: proto.OpSetRepairingStatus,
Request: req,
}
p = newPacketForTest(task)
dn.handlePacketToSetRepairingStatus(p)
require.Equal(t, proto.OpOk, p.ResultCode)
// forbid extent write
dataStr := "HelloWorld"
p = newPacketForOperatorTest(t, dp, extentId)
p.Opcode = proto.OpWrite
p.Data = []byte(dataStr)
p.ExtentOffset = 0
p.Size = uint32(len(p.Data))
dn.handleWritePacket(p)
t.Logf("handle write packet, result code(%v)", p.ResultCode)
require.EqualValues(t, proto.OpDpDecommissionRepairErr, p.ResultCode)
// forbid extent deletion
exts := make([]*proto.DelExtentParam, 0)
exts = append(exts, &proto.DelExtentParam{
ExtentKey: &proto.ExtentKey{
ExtentId: extentId,
PartitionId: dp.partitionID,
},
})
p = new(repl.Packet)
p.Opcode = proto.OpBatchDeleteExtent
p.ExtentType = proto.NormalExtentType
p.Object = dp
p.Data, _ = json.Marshal(exts)
p.Size = uint32(len(p.Data))
dn.handleBatchMarkDeletePacket(p, nil)
t.Logf("handle delete extent packet, result code(%v)", p.ResultCode)
require.EqualValues(t, proto.OpDpDecommissionRepairErr, p.ResultCode)
})
}
func newPacketForTest(task *proto.AdminTask) *repl.Packet {
data, _ := json.Marshal(task)
return &repl.Packet{

View File

@ -129,7 +129,7 @@ func (m *metadataManager) opMasterHeartbeat(conn net.Conn, p *Packet,
goto end
}
if !m.useLocalGOGC {
if m.gogcValue != req.MetaNodeGOGC {
if m.gogcValue != req.MetaNodeGOGC && req.MetaNodeGOGC >= defaultGOGCLowerLimit && req.MetaNodeGOGC <= defaultGOGCUpperLimit {
oldGOGC := m.gogcValue
debug.SetGCPercent(req.MetaNodeGOGC)
m.gogcValue = req.MetaNodeGOGC