Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a panic when trying to stop boltdb-shipper multiple times using sync.once #2613

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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