goharbor/harbor · error

failed to run SQL "SELECT 1

Error message

failed to run SQL "SELECT 1": %v

What it means

Error from databaseHealthChecker's periodic CheckFunc: executing the trivial probe query "SELECT 1" via the Beego ORM failed, meaning the Harbor database is unreachable, credentials are wrong, or the connection pool is exhausted.

Solutions

  1. Check database availability, network reachability, and credentials.
  2. Inspect connection-pool exhaustion or max-connection limits on the DB.
  3. Wait for the next periodic check (10s) once the database recovers.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/controller/health/checker.go:154 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/08f6ab92d6782feb. Report an issue: GitHub.

Appendix: source

Thrown at src/controller/health/checker.go:154

	period := 10 * time.Second
	checker := HTTPStatusCodeHealthChecker(http.MethodGet, url, nil, timeout, http.StatusOK)
	return PeriodicHealthChecker(checker, period)
}

func registryCtlHealthChecker() health.Checker {
	url := config.GetRegistryCtlURL() + "/api/health"
	timeout := 60 * time.Second
	period := 10 * time.Second
	checker := HTTPStatusCodeHealthChecker(http.MethodGet, url, nil, timeout, http.StatusOK)
	return PeriodicHealthChecker(checker, period)
}

func databaseHealthChecker() health.Checker {
	period := 10 * time.Second
	checker := health.CheckFunc(func() error {
		_, err := orm.NewOrm().Raw("SELECT 1").Exec()
		if err != nil {
			return fmt.Errorf("failed to run SQL \"SELECT 1\": %v", err)
		}
		return nil
	})
	return PeriodicHealthChecker(checker, period)
}

func redisHealthChecker() health.Checker {
	period := 10 * time.Second
	checker := health.CheckFunc(func() error {
		return cache.Default().Ping(context.TODO())
	})
	return PeriodicHealthChecker(checker, period)
}

func trivyHealthChecker() health.Checker {
	url := strings.TrimSuffix(config.TrivyAdapterURL(), "/") + "/probe/healthy"
	timeout := 60 * time.Second
	period := 10 * time.Second

View on GitHub (pinned to 7b2fd08cc5)