Skip to content

Commit

Permalink
exported UnloadIndex checks for ready state
Browse files Browse the repository at this point in the history
(cherry picked from commit 4a61140)
  • Loading branch information
stuartcarnie committed Sep 5, 2017
1 parent 1381c23 commit 0175369
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tsdb/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ type Shard struct {
path string
walPath string
id uint64
wg sync.WaitGroup

database string
retentionPolicy string
Expand Down Expand Up @@ -345,11 +344,10 @@ func (s *Shard) close(clean bool) error {
default:
close(s.closing)
}
s.wg.Wait()

if clean {
// Don't leak our shard ID and series keys in the index
s.UnloadIndex()
s.unloadIndex()
}

err := s.engine.Close()
Expand Down Expand Up @@ -398,6 +396,13 @@ func (s *Shard) LastModified() time.Time {

// UnloadIndex removes all references to this shard from the DatabaseIndex
func (s *Shard) UnloadIndex() {
if err := s.ready(); err != nil {
return
}
s.unloadIndex()
}

func (s *Shard) unloadIndex() {
s.index.RemoveShard(s.id)
}

Expand Down

0 comments on commit 0175369

Please sign in to comment.