Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClusterPipeline will not return connection when exception happened #3142

Closed
holidayQi opened this issue Sep 19, 2022 · 0 comments · Fixed by #3143
Closed

ClusterPipeline will not return connection when exception happened #3142

holidayQi opened this issue Sep 19, 2022 · 0 comments · Fixed by #3143
Labels
Milestone

Comments

@holidayQi
Copy link

Expected behavior

I use ClusterPipeline like this

        try (ClusterPipeline clusterPipeline = new ClusterPipeline(clusterConnectionProvider)) {
            List<Response<String>> tmpResults = new ArrayList<>(keys.size());
            keys.forEach(key -> {
                if (key != null) {
                    tmpResults.add(clusterPipeline.get(key));
                } else {
                    tmpResults.add(null);
                }
            });
            clusterPipeline.sync();
            return tmpResults.stream().map(r -> r != null ? r.get() : null).collect(Collectors.toList());
        }

when redis has exception, sync method will not marked synced true

  public final void sync() {
    if (synced) {
      return;
    }
    for (Map.Entry<HostAndPort, Queue<Response<?>>> entry : pipelinedResponses.entrySet()) {
      HostAndPort nodeKey = entry.getKey();
      Queue<Response<?>> queue = entry.getValue();
      List<Object> unformatted = connections.get(nodeKey).getMany(queue.size());
      for (Object o : unformatted) {
        queue.poll().set(o);
      }
    }
    synced = true;
  }

so close will throw exception, and connection will not close

  public void close() {
    sync();
    for (Connection connection : connections.values()) {
      connection.close();
    }
  }

after some time, connection pool will throw 'timeout waiting for idle object'
Is it a problem, or I user it wrong

Actual behavior

return connection even exception happens

Redis / Jedis Configuration

Jedis version: 4.2.2

Redis version:

Java version: jdk 1.8

@sazzad16 sazzad16 added the bug label Sep 19, 2022
@sazzad16 sazzad16 added this to the 4.3.0 milestone Sep 19, 2022
@sazzad16 sazzad16 linked a pull request Sep 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants