Reduce lock content in AssignShard
The lock shows up under write load. It only needs to be assigned once so a read lock eliminates the contention.pull/8302/head
parent
eeaad877bc
commit
883b3dcbbb
10
tsdb/meta.go
10
tsdb/meta.go
|
@ -1121,7 +1121,17 @@ func NewSeries(key []byte, tags models.Tags) *Series {
|
|||
}
|
||||
|
||||
func (s *Series) AssignShard(shardID uint64) {
|
||||
s.mu.RLock()
|
||||
_, ok := s.shardIDs[shardID]
|
||||
s.mu.RUnlock()
|
||||
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
// Skip the existence check under the write lock because we're just storing
|
||||
// and empty struct.
|
||||
s.shardIDs[shardID] = struct{}{}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue