Redis version:4.0 springboot-data-redis:2.3.9.REALESE lettuce version:5.3.7.REALESE
The lettuce is default redis client. Autoconfigure in LettuceConnectionConfiguration may be has a bug like this
org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: Command timed out after 1 second(s)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:275)
at org.springframework.data.redis.connection.lettuce.LettuceSetCommands.convertLettuceAccessException(LettuceSetCommands.java:520)
at org.springframework.data.redis.connection.lettuce.LettuceSetCommands.sMembers(LettuceSetCommands.java:245)
at org.springframework.data.redis.connection.DefaultedRedisConnection.sMembers(DefaultedRedisConnection.java:791)
at org.springframework.data.redis.core.DefaultSetOperations.lambda$members$10(DefaultSetOperations.java:214)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96)
at org.springframework.data.redis.core.DefaultSetOperations.members(DefaultSetOperations.java:214)
at org.springframework.data.redis.core.DefaultBoundSetOperations.members(DefaultBoundSetOperations.java:152)
This Exception is occasional use RedisTemaple or StringRedisTemplate
Use Jedis can be solved but not the best.
Comment From: wilkinsona
The exception message suggests that the timeout has been set at 1 second. Unless you have configured a different timeout, Lettuce should use a default command timeout of 60 seconds. From what you've shared thus far, this appears to be a configuration problem rather than a bug in Spring Boot. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: farsunset
Use Jedis can be solved
The exception message suggests that the timeout has been set at 1 second. Unless you have configured a different timeout, Lettuce should use a default command timeout of 60 seconds. From what you've shared thus far, this appears to be a configuration problem rather than a bug in Spring Boot. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: snicoll
@farsunset using a completely different driver is no indication that this isn't a configuration problem. As Andy mentioned, if you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem.
Comment From: farsunset
That is Minimal probability。config code look this
spring.redis.host = xxxxxxxxxx.redis.rds.aliyuncs.com
spring.redis.port = 6379
spring.redis.password = xxxxxxx
spring.redis.timeout = 1000
spring.redis.lettuce.pool.min-idle = 100
spring.redis.lettuce.pool.max-active = 100
spring.redis.lettuce.pool.max-idle = 100
spring.redis.lettuce.pool.max-wait = 1500
@Bean
public LettuceConnectionFactory redisConnectionFactory(LettuceClientConfiguration clientConfiguration,RedisProperties properties) {
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
configuration.setHostName(properties.getHost());
configuration.setPort(properties.getPort());
configuration.setPassword(RedisPassword.of(properties.getPassword()));
return new LettuceConnectionFactory(configuration, clientConfiguration);
}
@Bean
LettuceClientConfiguration lettuceClientConfiguration(ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers,
RedisProperties properties){
GenericObjectPoolConfig<?> genericObjectPoolConfig = new GenericObjectPoolConfig<>();
genericObjectPoolConfig.setMaxIdle(properties.getLettuce().getPool().getMaxIdle());
genericObjectPoolConfig.setMinIdle(properties.getLettuce().getPool().getMinIdle());
genericObjectPoolConfig.setMaxTotal(properties.getLettuce().getPool().getMaxActive());
genericObjectPoolConfig.setMaxWaitMillis(properties.getLettuce().getPool().getMaxWait().toMillis());
SocketOptions socketOptions = SocketOptions.builder().keepAlive(true).tcpNoDelay(true).connectTimeout(properties.getTimeout()).build();
LettuceClientConfiguration.LettuceClientConfigurationBuilder builder = LettucePoolingClientConfiguration.builder()
.commandTimeout(properties.getTimeout())
.shutdownTimeout(properties.getLettuce().getShutdownTimeout())
.clientOptions(ClientOptions.builder().socketOptions(socketOptions).build())
.clientResources(DefaultClientResources.create())
.poolConfig(genericObjectPoolConfig);
builderCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder));
return builder.build();
}
Comment From: farsunset
At the same time. i hava 8 times commonds to execute
Comment From: snicoll
@farsunset we're not asking for some code that might replicate the issue but a sample we can run. I'd recommend to create a project from start.spring.io and tune it to reproduce the issue you've described. Once that's the case, please post a zip of the projet or push it to a GitHub repository. Thank you.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: farsunset
i said this exception is Irreproducible , would you list all reason for this exception
Comment From: snicoll
This was already done in the first comment:
The exception message suggests that the timeout has been set at 1 second. Unless you have configured a different timeout, Lettuce should use a default command timeout of 60 seconds.
If you can't share a sample that lets us investigate the problem, I am afraid we can't justify spending the time providing support. I am going to close this now but we can reopen if you provide a sample that showcases the problem.