Skip to content

Commit

Permalink
fix a panic when trying to stop boltdb-shipper multiple times using s…
Browse files Browse the repository at this point in the history
…ync.once (#2613)
  • Loading branch information
sandeepsukhani authored Sep 10, 2020
1 parent ac84041 commit e53d203
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/storage/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ func TestStore_MultipleBoltDBShippersInConfig(t *testing.T) {
}}, limits, nil)
require.NoError(t, err)

defer store.Stop()

// time ranges adding a chunk for each store and a chunk which overlaps both the stores
chunksToBuildForTimeRanges := []timeRange{
{
Expand Down
8 changes: 7 additions & 1 deletion pkg/storage/stores/shipper/shipper_index_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"path"
"sync"
"time"

"github.com/cortexproject/cortex/pkg/chunk"
Expand Down Expand Up @@ -76,7 +77,8 @@ type Shipper struct {
uploadsManager *uploads.TableManager
downloadsManager *downloads.TableManager

metrics *metrics
metrics *metrics
stopOnce sync.Once
}

// NewShipper creates a shipper for syncing local objects with a store
Expand Down Expand Up @@ -179,6 +181,10 @@ func (s *Shipper) getUploaderName() (string, error) {
}

func (s *Shipper) Stop() {
s.stopOnce.Do(s.stop)
}

func (s *Shipper) stop() {
if s.uploadsManager != nil {
s.uploadsManager.Stop()
}
Expand Down

0 comments on commit e53d203

Please sign in to comment.