diff --git a/pkg/kv/kvserver/replica_raft.go b/pkg/kv/kvserver/replica_raft.go index 9f587564479b..6fff45fa9d06 100644 --- a/pkg/kv/kvserver/replica_raft.go +++ b/pkg/kv/kvserver/replica_raft.go @@ -1588,9 +1588,11 @@ func (r *Replica) maybeCoalesceHeartbeat( switch msg.Type { case raftpb.MsgHeartbeat: r.store.coalescedMu.Lock() + defer r.store.coalescedMu.Unlock() hbMap = r.store.coalescedMu.heartbeats case raftpb.MsgHeartbeatResp: r.store.coalescedMu.Lock() + defer r.store.coalescedMu.Unlock() hbMap = r.store.coalescedMu.heartbeatResponses default: return false @@ -1613,7 +1615,6 @@ func (r *Replica) maybeCoalesceHeartbeat( NodeID: toReplica.NodeID, } hbMap[toStore] = append(hbMap[toStore], beat) - r.store.coalescedMu.Unlock() return true }