From 7fbd36c99c9eff964df020518a79b5129a7a40c4 Mon Sep 17 00:00:00 2001 From: a6802739 Date: Thu, 12 Oct 2017 16:33:24 +0800 Subject: [PATCH] storage : fix bug for the testrace of TestSystemZoneConfigs Fixes #19180. Fixes #19207. --- pkg/storage/allocator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/storage/allocator.go b/pkg/storage/allocator.go index 39c06edbb04f..cbefd5c153ff 100644 --- a/pkg/storage/allocator.go +++ b/pkg/storage/allocator.go @@ -526,7 +526,11 @@ func (a Allocator) RebalanceTarget( StoreID: target.store.StoreID, ReplicaID: rangeInfo.Desc.NextReplicaID, } + + // Deep-copy the Replicas slice since we'll mutate it. desc := *rangeInfo.Desc + desc.Replicas = append([]roachpb.ReplicaDescriptor(nil), desc.Replicas...) + desc.Replicas = append(desc.Replicas, newReplica) rangeInfo.Desc = &desc