Skip to content

Commit

Permalink
Store: Make initial sync more robust
Browse files Browse the repository at this point in the history
Added re-try mechanism for store inital sync, where if the initial sync fails, it tries to do the initial sync again every 5 seconds for 15 seconds duration (total 3 re-tries for initial sync of store).

Signed-off-by: Kartik-Garg <kartik.garg@infracloud.io>
  • Loading branch information
Kartik-Garg committed Jan 18, 2023
2 parents 853b960 + e85223b commit 7cf7292
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/thanos/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ import (
"github.com/thanos-io/thanos/pkg/ui"
)

// const (
// timeoutDuration = 15
// intervalDuration = 5
// )
const (
timeoutDuration = 15
intervalDuration = 5
)

type storeConfig struct {
indexCacheConfigs extflag.PathOrContent
Expand Down Expand Up @@ -388,11 +388,11 @@ func runStore(
begin := time.Now()

//This will stop retrying after 15 seconds.
initialSyncCtx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
initialSyncCtx, cancel := context.WithTimeout(context.Background(), timeoutDuration*time.Second)
defer cancel()

//If error occurs, it will re-try after every 5 seconds, but only for 15 seconds, (so total re-try is three).
err := runutil.Retry(5*time.Second, initialSyncCtx.Done(), func() error {
err := runutil.Retry(intervalDuration*time.Second, initialSyncCtx.Done(), func() error {
return bs.InitialSync(ctx)
})

Expand Down

0 comments on commit 7cf7292

Please sign in to comment.