iflytek/astron-agent · critical · DistributedLockException
REDIS_CONNECTION_ERROR
REDIS_CONNECTION_ERROR
Error message
Failed to get lock object: ${e.getMessage()} What it means
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.
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
Defensive patterns
Strategy: retry
Validate before calling
// health check before use: redissonClient.getNodesGroup().getNodes().forEach(n -> n.ping());
Try / catch
try { return locked(); } catch (DistributedLockException e) { if (e.getErrorType() == LockErrorType.REDIS_CONNECTION_ERROR) { throw new ServiceUnavailableException("locking backend down", e); } throw e; } Prevention
- 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
When it happens
Trigger: redissonClient.getLock/getFairLock/getReadWriteLock throws — e.g. Redisson not initialized, wrong Redis address, auth failure, or connection pool exhausted at call time.
Common situations: 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.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- RELEASE_FAILED
- Timed out acquiring distributed lock, please try again later
- Distributed lock acquisition timeout, please try again later
- ACQUIRE_TIMEOUT
- ExecuteShutdown unlock threw exception. key=
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/c70651e8c9251479.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/aspect/DistributedLockAspect.java:181
* Get corresponding lock object based on lock type
*/
private RLock getLock(String lockKey, DistributedLock.LockType lockType) {
try {
return switch (lockType) {
case REENTRANT -> redissonClient.getLock(lockKey);
case FAIR -> redissonClient.getFairLock(lockKey);
case READ -> {
RReadWriteLock readWriteLock = redissonClient.getReadWriteLock(lockKey);
yield readWriteLock.readLock();
}
case WRITE -> {
RReadWriteLock readWriteLock = redissonClient.getReadWriteLock(lockKey);
yield readWriteLock.writeLock();
}
};
} catch (Exception e) {
log.error("Failed to get lock object: key={}, lockType={}, error={}", lockKey, lockType, e.getMessage(), e);
throw new DistributedLockException(lockKey,
DistributedLockException.LockErrorType.REDIS_CONNECTION_ERROR,
"Failed to get lock object: " + e.getMessage(), e);
}
}
/**
* Try to acquire lock
*/
private boolean tryLock(RLock lock, DistributedLock distributedLock) throws InterruptedException {
if (distributedLock.waitTime() <= 0) {
// Don't wait, try to acquire lock immediately
if (distributedLock.leaseTime() > 0) {
return lock.tryLock(0, distributedLock.leaseTime(), distributedLock.timeUnit());
} else {
return lock.tryLock();
}
} else {
// Wait for specified time to acquire lockView on GitHub (pinned to 5e758547a8)