Skip to content

Commit

Permalink
fix: add mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
devanbenz committed Oct 17, 2024
1 parent c9331f0 commit 6f4aa66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tsdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ func (s *Store) Shard(id uint64) *Shard {
// longer in a "bad" state. This method will return any shards that
// were removed from the cache.
func (s *Store) ClearBadShardList() map[uint64]error {
s.mu.Lock()
defer s.mu.Unlock()

badShards := s.GetBadShardList()
clear(s.badShards.shardErrors)

Expand Down
2 changes: 1 addition & 1 deletion tsdb/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func TestStore_BadShardClear(t *testing.T) {
require.ErrorIs(t, err2, tsdb.ErrPreviousShardFail{})
require.EqualError(t, err2, fmt.Errorf("not attempting to open shard %d; opening shard previously failed with: %w", shId, expErr).Error())

require.Equal(t, 1, len(s.Store.GetBadShardList()))
require.Len(t, s.Store.GetBadShardList(), 1)

badShards := s.ClearBadShardList()
require.Len(t, badShards, 1)
Expand Down

0 comments on commit 6f4aa66

Please sign in to comment.