From 764d1e496df91fe32e38dd721a12e358fbeef2a5 Mon Sep 17 00:00:00 2001 From: xrefft Date: Thu, 1 Apr 2021 19:49:01 +0800 Subject: [PATCH] fix bug when packet opCode=OpExtentRepairRead and network is unstable Signed-off-by: mingwei --- datanode/data_partition_repair.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/datanode/data_partition_repair.go b/datanode/data_partition_repair.go index 80857e0a2..c41ec2124 100644 --- a/datanode/data_partition_repair.go +++ b/datanode/data_partition_repair.go @@ -534,7 +534,7 @@ func (dp *DataPartition) streamRepairExtent(remoteExtentInfo *storage.ExtentInfo if reply.ResultCode != proto.OpOk { err = errors.Trace(fmt.Errorf("unknow result code"), - "streamRepairExtent receive opcode error(%v) ,localExtentSize(%v) remoteExtentSize(%v)", string(reply.Data[:reply.Size]), currFixOffset, remoteExtentInfo.Size) + "streamRepairExtent receive opcode error(%v) ,localExtentSize(%v) remoteExtentSize(%v)", string(reply.Data[:intMin(len(reply.Data), int(reply.Size))]), currFixOffset, remoteExtentInfo.Size) return } @@ -602,3 +602,11 @@ func (dp *DataPartition) streamRepairExtent(remoteExtentInfo *storage.ExtentInfo return } + +func intMin(a, b int) int { + if a < b { + return a + } else { + return b + } +}