lettuce icon indicating copy to clipboard operation
lettuce copied to clipboard

The socket channels to redis sentinels would increasing unlimitedly.

Open leonlibraries opened this issue 1 year ago • 5 comments

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

leonlibraries avatar Sep 07 '22 06:09 leonlibraries

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.

luis6156 avatar Sep 26 '22 10:09 luis6156

Can you provide a minimal reproducer that shows how you use Lettuce?

mp911de avatar Sep 26 '22 11:09 mp911de

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;
}

luis6156 avatar Sep 26 '22 12:09 luis6156

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.

mp911de avatar Nov 22 '22 09:11 mp911de

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.

github-actions[bot] avatar Apr 26 '24 00:04 github-actions[bot]