{"record":{"id":"eec38ad28253b77e","repo":"argoproj/argo-workflows","slug":"database-session-is-not-available-for-semaphore-s","errorCode":null,"errorMessage":"database session is not available for semaphore %s","messagePattern":"database session is not available for semaphore (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"workflow/sync/sync_manager.go","lineNumber":856,"sourceCode":"\nfunc (sm *Manager) getCurrentLockHolders(ctx context.Context, lock string) ([]string, error) {\n\tif concurrency, ok := sm.syncLockMap[lock]; ok {\n\t\treturn concurrency.getCurrentHolders(ctx)\n\t}\n\treturn nil, nil\n}\n\nfunc (sm *Manager) initializeSemaphore(ctx context.Context, semaphoreName string) (semaphore, error) {\n\tlock, err := DecodeLockName(ctx, semaphoreName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch lock.getKind() {\n\tcase lockKindConfigMap:\n\t\treturn newInternalSemaphore(ctx, semaphoreName, sm.nextWorkflow, sm.getSyncLimit, sm.syncLimitCacheTTL)\n\tcase lockKindDatabase:\n\t\tif sm.dbInfo.SessionProxy == nil {\n\t\t\treturn nil, fmt.Errorf(\"database session is not available for semaphore %s\", semaphoreName)\n\t\t}\n\t\treturn newDatabaseSemaphore(ctx, semaphoreName, lock.getDBKey(), sm.nextWorkflow, sm.dbInfo, sm.syncLimitCacheTTL)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid lock kind %s when initializing semaphore\", lock.getKind())\n\t}\n}\n\nfunc (sm *Manager) initializeMutex(ctx context.Context, mutexName string) (semaphore, error) {\n\tlock, err := DecodeLockName(ctx, mutexName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch lock.getKind() {\n\tcase lockKindMutex:\n\t\treturn newInternalMutex(mutexName, sm.nextWorkflow), nil\n\tcase lockKindDatabase:\n\t\tif sm.dbInfo.SessionProxy == nil {\n\t\t\treturn nil, fmt.Errorf(\"database session is not available for mutex %s\", mutexName)","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/sync/sync_manager.go#L838-L874","documentation":"initializeSemaphore builds a semaphore for a decoded lock; for lockKindDatabase it requires the manager's DB session proxy and returns 'database session is not available for semaphore <name>' when it is nil. Called during prepAcquire, this blocks acquisition of any DB-backed semaphore when persistence is not configured.","triggerScenarios":"prepAcquire resolves a lock decoded as lockKindDatabase while sm.dbInfo.SessionProxy is nil — DB-backed sync config exists but the controller has no sync DB session (persistence disabled or DB down at init).","commonSituations":"Deploying workflows with SQL-backed synchronization on a controller without DB persistence; wrong DB credentials so the session proxy never initialized; DB lost after controller start.","solutions":["Enable synchronization DB persistence in the controller configuration","Verify DB credentials/connectivity so SessionProxy initializes at startup","Restart the controller after fixing persistence config","Convert the semaphore to ConfigMap-based if DB sync is unnecessary"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"lock, _ := sync.DecodeLockName(ctx, key)\nif lock.GetKind() == sync.LockKindDatabase && !dbSessionReady(manager) {\n    return errors.New(\"DB-backed semaphore requires configured sync persistence\")\n}","typeGuard":"func canUseDBLock(sm *sync.Manager) bool { return sm != nil && sm.DBInfo != nil && sm.DBInfo.SessionProxy != nil }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"database session is not available for semaphore\") { /* configure persistence, requeue */ }","preventionTips":["Health-check the sync DB session at controller startup","Use readiness probes that reflect sync DB availability","Keep persistence config and workflow sync usage in sync"],"tags":["argo-workflows","sync","database","semaphore","persistence"],"backgroundTag":"missing-database-session","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"}