From 63230f0280bc8612d7d6a7f27a798089b6b1477d Mon Sep 17 00:00:00 2001 From: congqixia Date: Tue, 5 Jul 2022 13:16:20 +0800 Subject: [PATCH] Fix data race in ShardCluster.SyncReplicas (#18054) Signed-off-by: Congqi Xia --- internal/querynode/shard_cluster.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/querynode/shard_cluster.go b/internal/querynode/shard_cluster.go index f6d6808b39..486521922c 100644 --- a/internal/querynode/shard_cluster.go +++ b/internal/querynode/shard_cluster.go @@ -301,6 +301,8 @@ func (sc *ShardCluster) SyncSegments(distribution []*querypb.ReplicaSegmentsInfo }) } } + + allocations := sc.segments.Clone(filterNothing) sc.mut.Unlock() // notify handoff wait online if any @@ -310,7 +312,7 @@ func (sc *ShardCluster) SyncSegments(distribution []*querypb.ReplicaSegmentsInfo sc.mutVersion.Lock() defer sc.mutVersion.Unlock() - version := NewShardClusterVersion(sc.nextVersionID.Inc(), sc.segments.Clone(filterNothing)) + version := NewShardClusterVersion(sc.nextVersionID.Inc(), allocations) sc.versions.Store(version.versionID, version) sc.currentVersion = version }