lxd/db/query/retry.go
func Retry(f func() error) error {
	// TODO: the retry loop should be configurable.
	var err error
	for i := 0; i < 5; i++ {
		err = f()
		if err != nil {
			logger.Debugf("Database error: %#v", err)

			if IsRetriableError(err) {
				logger.Debugf("Retry failed db interaction (%v)", err)
				time.Sleep(250 * time.Millisecond)
				continue
			}
		}
		break
	}
	return err
}
func Retry(f func() error) error {
	// TODO: the retry loop should be configurable.
	var err error
	for i := 0; i < 5; i++ {
		err = f()
		if err != nil {
			logger.Debugf("Database error: %#v", err)

			if IsRetriableError(err) {
				logger.Debugf("Retry failed db interaction (%v)", err)
				time.Sleep(250 * time.Millisecond)
				continue
			}
		}
		break
	}
	return err
}
// Retry wraps a function that interacts with the database, and retries it in
// case a transient error is hit.
//
// This should by typically used to wrap transactions.