Skip to content

ScanIteration (JedisCommandIterationBase) connection leak with JedisSentineled #4323

@veselov

Description

@veselov

Not sure I fully understand what's going on, so looking for some idea on how to even approach fixing this.

            var jedis = new JedisSentineled(....);
            var it = j.scanIteration(100, cacheObjKey()+"*");
            // doesn't really matter what happens past the line above
            while (!it.isIterationCompleted()) {
                var data = it.nextBatchList().toArray(new String[0]);
                if (data.length > 0) {
                    j.del(data);
                }
            }

This leaks a connection for me.
JedisCommandIterationBase's constructor calls connectionProvider.getConnectionMap(), which is default ConnectionProvider's getConnectionMap(), which just allocates a connection, puts in a single-element map, and returns that. JedisCommandIterationBase is not a Closeable, and never clears that connection out (because it doesn't think it needs to).

It looks like pool-based connection providers must return a pool from a getConnectionMap(), like PooledConnectionProvider does. SentinelConnectionProvider doesn't do that. But it's also not easy for it to do that because its pool is volatile.

Any ideas how to work around this in the meantime?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions