Fix shard epoch race.

pull/11791/head
Ben Johnson 2019-02-11 12:15:46 -07:00
parent 198f6fde38
commit b87605f521
No known key found for this signature in database
GPG Key ID: 81741CD251883081
1 changed files with 5 additions and 2 deletions

View File

@ -1373,11 +1373,14 @@ func (s *Store) WriteToShard(shardID uint64, points []models.Point) error {
s.mu.RUnlock()
return ErrShardNotFound
}
epoch := s.epochs[shardID]
s.mu.RUnlock()
// enter the epoch tracker
guards, gen := s.epochs[shardID].StartWrite()
defer s.epochs[shardID].EndWrite(gen)
guards, gen := epoch.StartWrite()
defer epoch.EndWrite(gen)
// wait for any guards before writing the points.
for _, guard := range guards {