{"record":{"id":"c70651e8c9251479","repo":"iflytek/astron-agent","slug":"redis-connection-error","errorCode":"REDIS_CONNECTION_ERROR","errorMessage":"Failed to get lock object: ${e.getMessage()}","messagePattern":"Failed to get lock object: (.+?)","errorType":"exception","errorClass":"DistributedLockException","httpStatus":null,"severity":"critical","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/aspect/DistributedLockAspect.java","lineNumber":181,"sourceCode":"     * Get corresponding lock object based on lock type\n     */\n    private RLock getLock(String lockKey, DistributedLock.LockType lockType) {\n        try {\n            return switch (lockType) {\n                case REENTRANT -> redissonClient.getLock(lockKey);\n                case FAIR -> redissonClient.getFairLock(lockKey);\n                case READ -> {\n                    RReadWriteLock readWriteLock = redissonClient.getReadWriteLock(lockKey);\n                    yield readWriteLock.readLock();\n                }\n                case WRITE -> {\n                    RReadWriteLock readWriteLock = redissonClient.getReadWriteLock(lockKey);\n                    yield readWriteLock.writeLock();\n                }\n            };\n        } catch (Exception e) {\n            log.error(\"Failed to get lock object: key={}, lockType={}, error={}\", lockKey, lockType, e.getMessage(), e);\n            throw new DistributedLockException(lockKey,\n                DistributedLockException.LockErrorType.REDIS_CONNECTION_ERROR,\n                \"Failed to get lock object: \" + e.getMessage(), e);\n        }\n    }\n\n    /**\n     * Try to acquire lock\n     */\n    private boolean tryLock(RLock lock, DistributedLock distributedLock) throws InterruptedException {\n        if (distributedLock.waitTime() <= 0) {\n            // Don't wait, try to acquire lock immediately\n            if (distributedLock.leaseTime() > 0) {\n                return lock.tryLock(0, distributedLock.leaseTime(), distributedLock.timeUnit());\n            } else {\n                return lock.tryLock();\n            }\n        } else {\n            // Wait for specified time to acquire lock","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/aspect/DistributedLockAspect.java#L163-L199","documentation":"getLock asks Redisson for the lock object (lock, fair lock, read/write lock, etc. by lockType) and throws DistributedLockException(REDIS_CONNECTION_ERROR) if obtaining it fails. This usually indicates the Redis/Redisson client is not connected or misconfigured, so no locking can proceed.","triggerScenarios":"redissonClient.getLock/getFairLock/getReadWriteLock throws — e.g. Redisson not initialized, wrong Redis address, auth failure, or connection pool exhausted at call time.","commonSituations":"Redis down or restarting in the environment; wrong spring.data.redis address/password config; Redisson version/config change after upgrade; network policy blocking port 6379 in k8s.","solutions":["Check log 'Failed to get lock object: key=..., lockType=...' for the underlying error","Verify Redis is reachable (redis-cli ping) and credentials are correct","Review Redisson client config (address, database, pool size) for the environment","Add connection retry/health checks and ensure Redisson bean is initialized before AOP use"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// health check before use: redissonClient.getNodesGroup().getNodes().forEach(n -> n.ping());","typeGuard":null,"tryCatchPattern":"try { return locked(); } catch (DistributedLockException e) { if (e.getErrorType() == LockErrorType.REDIS_CONNECTION_ERROR) { throw new ServiceUnavailableException(\"locking backend down\", e); } throw e; }","preventionTips":["Add Redis liveness/readiness probes and alerts","Pin and test Redisson config per environment","Fail fast at startup if Redisson cannot connect rather than at first request"],"tags":["redis","redisson","distributed-lock","connectivity"],"backgroundTag":"connection-refused","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}