Fix data race in ShardCluster.SyncReplicas (#18054) (#18059)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2022-07-05 18:30:20 +08:00 committed by GitHub
parent dba779e8c5
commit 2dee6534a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}