Skip to content

Commit

Permalink
Merge pull request #740 from Icinga/retry-schema-check
Browse files Browse the repository at this point in the history
icingadb.DB: Retry Schema Checks
  • Loading branch information
julianbrost authored Apr 11, 2024
2 parents 109372f + fab2765 commit 889a153
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/icingadb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,19 @@ func (db *DB) CheckSchema(ctx context.Context) error {

var version uint16

err := db.QueryRowxContext(ctx, "SELECT version FROM icingadb_schema ORDER BY id DESC LIMIT 1").Scan(&version)
err := retry.WithBackoff(
ctx,
func(ctx context.Context) (err error) {
query := "SELECT version FROM icingadb_schema ORDER BY id DESC LIMIT 1"
err = db.QueryRowxContext(ctx, query).Scan(&version)
if err != nil {
err = internal.CantPerformQuery(err, query)
}
return
},
retry.Retryable,
backoff.NewExponentialWithJitter(128*time.Millisecond, 1*time.Minute),
db.getDefaultRetrySettings())
if err != nil {
return errors.Wrap(err, "can't check database schema version")
}
Expand Down

0 comments on commit 889a153

Please sign in to comment.