ory/hydra · error
could not set GOMAXPROCS: %w
Error message
could not set GOMAXPROCS: %w
What it means
driver/registry_sql.go Init wraps a maxprocs.Set failure with "could not set GOMAXPROCS: %w". When cgroups-based auto GOMAXPROCS is enabled (CGroupsV1AutoMaxProcsEnabled), the driver uses uber-go/automaxprocs to align GOMAXPROCS with the container CPU quota; failure here aborts initialization.
Source
Thrown at driver/registry_sql.go:196
// of RegistrySQL.initialPing.
func defaultInitialPing(ctx context.Context, l *logrusx.Logger, p *sql.BasePersister) error {
return errors.WithStack(resilience.Retry(l, 5*time.Second, 5*time.Minute, func() error {
return p.Ping(ctx)
}))
}
func (m *RegistrySQL) Init(
ctx context.Context,
skipNetworkInit bool,
migrate bool,
extraMigrations []fs.FS,
goMigrations []popx.Migration,
) error {
if m.basePersister == nil {
if m.Config().CGroupsV1AutoMaxProcsEnabled() {
_, err := maxprocs.Set(maxprocs.Logger(m.Logger().Infof))
if err != nil {
return fmt.Errorf("could not set GOMAXPROCS: %w", err)
}
}
// new db connection
pool, idlePool, connMaxLifetime, connMaxIdleTime, cleanedDSN := sqlcon.ParseConnectionOptions(
m.l, m.Config().DSN(),
)
opts := &pop.ConnectionDetails{
URL: sqlcon.FinalizeDSN(m.l, cleanedDSN),
IdlePool: idlePool,
ConnMaxLifetime: connMaxLifetime,
ConnMaxIdleTime: connMaxIdleTime,
Pool: pool,
TracerProvider: m.Tracer(ctx).Provider(),
Unsafe: m.Config().DbIgnoreUnknownTableColumns(),
}
View on GitHub (pinned to 4174065ffb)
Solutions
- Disable the auto max procs setting (e.g. set the cgroups v1 auto max procs config flag to false) and set GOMAXPROCS explicitly via env
- Mount cgroup v1 or check the underlying wrapped error for the exact read failure
- Upgrade to a version that supports cgroup v2 detection
- Run with privileged/sysfs access if in a restricted sandbox
Example fix
# before # dsn: ... (cgroups auto max procs enabled) # after GOMAXPROCS=2 hydra serve all # or disable cgroups_v1_auto_max_procs in config
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := os.Stat("/sys/fs/cgroup"); err != nil {
log.Println("cgroup fs unavailable: disable auto max procs")
} Try / catch
if err != nil {
log.Warnf("maxprocs: %v - continuing with default GOMAXPROCS", err)
} Prevention
- Prefer explicit GOMAXPROCS env in containers
- Verify cgroup mounts in CI sandboxes
- Keep automaxprocs version current
When it happens
Trigger: Starting Hydra with cgroups auto-max-procs enabled in an environment where /sys/fs/cgroup (cgroup v1) files are unreadable or the mount is missing.
Common situations: Running in Docker/Kubernetes with cgroup v2 while the feature assumes v1, restricted container runtimes (gVisor, some CI sandboxes) hiding /proc/self/cgroup, or read-only /sys mounts.
Related errors
- issuer URL must be set unless development mode is enabled
- global secret is not configured
- cookiex: purpose must be non-empty and must not contain a pi
- cookiex: at least one secret is required
- cookiex: max age must not be negative
AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03).
Data as JSON: /api/errors/11c57c1f1dcb6e95.
Report an issue: GitHub.