Add lock before reading tSafeWatcher map (#8562)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/8555/merge
congqixia 2021-09-26 12:37:56 +08:00 committed by GitHub
parent c72f074009
commit 6f7f71fdc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -56,7 +56,7 @@ type queryCollection struct {
unsolvedMsgMu sync.Mutex // guards unsolvedMsg
unsolvedMsg []queryMsg
tSafeWatchersMu sync.Mutex // guards tSafeWatchers
tSafeWatchersMu sync.RWMutex // guards tSafeWatchers
tSafeWatchers map[Channel]*tSafeWatcher
tSafeUpdate bool
watcherCond *sync.Cond
@ -217,7 +217,8 @@ func (q *queryCollection) waitNewTSafe() (Timestamp, error) {
q.watcherCond.Wait()
}
q.watcherCond.L.Unlock()
//log.Debug("wait new tSafe", zap.Any("collectionID", s.collectionID))
q.tSafeWatchersMu.RLock()
defer q.tSafeWatchersMu.RUnlock()
t := Timestamp(math.MaxInt64)
for channel := range q.tSafeWatchers {
ts, err := q.streaming.tSafeReplica.getTSafe(channel)