lettuce
lettuce copied to clipboard
The socket channels to redis sentinels would increasing unlimitedly.
Bug Report
The socket channels to redis sentinels would increasing unlimitedly, especially when I use object pool.
Current Behavior
I trace the function of borrowing connection from the pool , I've found the socket channel from client to redis sentinel will be created when building every single one connection in the pool. And the channel group is never under control by GenericObjectPoolConfig.
My question is How could I avoid that connections to redis sentinels increasing unlimitedly?
Stack trace
class ChannelGroupListener extends ChannelInboundHandlerAdapter {
private final ChannelGroup channels;
private final EventBus eventBus;
public ChannelGroupListener(ChannelGroup channels, EventBus eventBus) {
this.channels = channels;
this.eventBus = eventBus;
}
...
}
Input Code
Input Code
// your code here;
Expected behavior/code
Environment
- Lettuce version(s): [e.g. 6.1.8.RELEASE]
- Redis version: [e.g. 4.0.8]
Possible Solution
Additional context
I am also facing the same issue, since version 6.1.0.M1 a lot of sockets seem to be opened, hence I run into an error as the maximum number of open sockets is reached.
Can you provide a minimal reproducer that shows how you use Lettuce?
Of course, thank you for the quick response.
@Bean
public RedisConnectionFactory redisConnectionFactory() {
org.springframework.data.redis.connection.RedisConfiguration redisConfiguration;
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration.setHostName(redisHost);
redisStandaloneConfiguration.setPort(redisPort);
redisStandaloneConfiguration.setPassword(password);
redisConfiguration = redisStandaloneConfiguration;
LettuceClientConfiguration.LettuceClientConfigurationBuilder lettuceClientConfigurationBuilder =
LettuceClientConfiguration.builder()
.commandTimeout(Duration.of(redisCommandTimeout, ChronoUnit.SECONDS));
LettuceClientConfiguration lettuceClientConfiguration = lettuceClientConfigurationBuilder.build();
LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(redisConfiguration, lettuceClientConfiguration);
lettuceConnectionFactory.setDatabase(database);
return lettuceConnectionFactory;
}
The example code doesn't match anything pooling related. ChannelGroupListener
is a collector to be able to close all open connections, not intended for pooling though.
Let me know whether there's still something left to do here.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 30 days this issue will be closed.