{"record":{"id":"2d1e1d20864abc5e","repo":"argoproj/argo-workflows","slug":"was-unable-to-create-database-connection","errorCode":null,"errorMessage":"was unable to create database connection","messagePattern":"was unable to create database connection","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/sync/sync_server.go","lineNumber":38,"sourceCode":"\tupdateSyncLimit(ctx context.Context, req *syncpkg.UpdateSyncLimitRequest) (*syncpkg.SyncLimitResponse, error)\n\tdeleteSyncLimit(ctx context.Context, req *syncpkg.DeleteSyncLimitRequest) (*syncpkg.DeleteSyncLimitResponse, error)\n}\n\ntype syncServer struct {\n\tproviders map[syncpkg.SyncConfigType]ConfigProvider\n}\n\nfunc NewSyncServer(ctx context.Context, kubectlConfig kubernetes.Interface, namespace string, syncConfig *config.SyncConfig) syncpkg.SyncServiceServer {\n\tserver := &syncServer{\n\t\tproviders: make(map[syncpkg.SyncConfigType]ConfigProvider),\n\t}\n\n\tserver.providers[syncpkg.SyncConfigType_CONFIGMAP] = &configMapSyncProvider{}\n\n\tif syncConfig != nil && syncConfig.EnableAPI {\n\t\tsessionProxy := syncdb.SessionProxyFromConfig(ctx, kubectlConfig, namespace, syncConfig)\n\t\tif sessionProxy == nil {\n\t\t\tpanic(\"was unable to create database connection\")\n\t\t}\n\t\tserver.providers[syncpkg.SyncConfigType_DATABASE] = &dbSyncProvider{db: syncdb.NewSyncQueries(sessionProxy, syncdb.ConfigFromConfig(syncConfig))}\n\t}\n\n\treturn server\n}\n\nfunc (s *syncServer) CreateSyncLimit(ctx context.Context, req *syncpkg.CreateSyncLimitRequest) (*syncpkg.SyncLimitResponse, error) {\n\tif req.Limit <= 0 {\n\t\treturn nil, sutils.ToStatusError(fmt.Errorf(\"limit must be greater than zero\"), codes.InvalidArgument)\n\t}\n\n\tprovider, ok := s.providers[req.Type]\n\tif !ok {\n\t\treturn nil, sutils.ToStatusError(fmt.Errorf(\"unsupported sync config type: %s\", req.Type), codes.InvalidArgument)\n\t}\n\treturn provider.createSyncLimit(ctx, req)\n}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/server/sync/sync_server.go#L20-L56","documentation":"NewSyncServer in server/sync/sync_server.go registers providers for semaphore/mutex synchronization. When the sync config has EnableAPI set, it creates a database-backed SessionProxy; if that proxy cannot be established (nil), the server panics because the DATABASE sync provider cannot work without a DB connection. This is a fail-fast at argo-server startup so misconfiguration is caught immediately.","triggerScenarios":"Starting `argo server` with syncConfig.EnableAPI=true while the database (Postgres/MySQL) is unreachable, misconfigured (bad host/credentials), or SessionProxyFromConfig fails to open a session and returns nil.","commonSituations":"Enabling the sync API without configuring persistence in workflow-controller-configmap; DB pod not yet ready during server startup; wrong DB host/port/credentials; network policy blocking the server from the database.","solutions":["Check the controller configmap syncConfig block: correct database host, port, user, password, and tableName","Confirm the database is reachable from the argo-server pod (kubectl exec + connection test)","If you do not need database-backed sync, remove enableAPI: true from the sync configuration","Check argo-server logs for the underlying DB error printed before the panic","Restart argo-server after the database becomes healthy"],"exampleFix":"# before\nsyncConfig:\n  enableAPI: true\n# after\nsyncConfig:\n  enableAPI: true\n  persistence:  # ensure DB settings exist / match your database\n    host: postgres\n    port: 5432\n    database: argo\n    userNameSecret:\n      name: argo-postgres-config\n      key: username\n    passwordSecret:\n      name: argo-postgres-config\n      key: password","handlingStrategy":"validation","validationCode":"cfg := getSyncConfig()\nif cfg != nil && cfg.EnableAPI {\n    if cfg.DatabaseHost == \"\" {\n        return errors.New(\"syncConfig.enableAPI requires database settings\")\n    }\n    if err := testDBConnection(cfg); err != nil {\n        return fmt.Errorf(\"database unreachable: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable syncConfig.enableAPI when persistence is configured and healthy","Order startup: database first, then argo-server (readiness gates)","Add a pre-deploy connectivity check from the argo-server pod to the DB","Keep DB credentials in secrets and verify they resolve before rollout"],"tags":["database","startup","panic","configuration","kubernetes"],"backgroundTag":"database-connection-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}