vertx-redis-client icon indicating copy to clipboard operation
vertx-redis-client copied to clipboard

Missing connection with endpoint fallback in cluster connection

Open jabolina opened this issue 2 years ago • 2 comments

Version

4.4.4

Context

This seems a corner-case, and likely people won't usually hit. By falling back to the endpoints given during configuration if a slot is not found:

https://github.com/vert-x3/vertx-redis-client/blob/a5a54f78f3836cf7ef21e8db6abc5d8436961a1a/src/main/java/io/vertx/redis/client/impl/RedisClusterConnection.java#L508-L511

The URI might contain some query parameters which cause the command to fail on:

https://github.com/vert-x3/vertx-redis-client/blob/a5a54f78f3836cf7ef21e8db6abc5d8436961a1a/src/main/java/io/vertx/redis/client/impl/RedisClusterConnection.java#L255-L260

More concretely, after executing the CLUSTER SLOTS command, the connections map to the endpoints returned, which has the format rediss://127.0.0.1:11222 (with SSL).

https://github.com/vert-x3/vertx-redis-client/blob/a5a54f78f3836cf7ef21e8db6abc5d8436961a1a/src/main/java/io/vertx/redis/client/impl/RedisClusterClient.java#L177-L179

If (for some unusual) reason the slot is not found, falling back to the configured endpoint might not be reliable, as the URI is not necessarily the same, e.g., rediss://127.0.0.1:11222?verifyPeer=NONE. Searching the connections map returns null for the endpoint.

Do you have a reproducer?

I am unsure of other ways to fall back to the configuration URI. So, sadly, I don't have a reproducer for this one. I believe this is really unlikely to happen, but I thought it might be worth reporting it.

jabolina avatar Oct 31 '23 17:10 jabolina

@Ladicek would you mind taking care of this one?

tsegismont avatar Nov 03 '23 11:11 tsegismont

Just for the record, I didn't forget about this. This is basically about canonicalizing the key to the connection pool map. I'd like to improve the code related to connection pooling more thoroughly [1], and will address this at that point.

[1] For example, there are some validations for connection pool configuration that assume we have a single connection pool, which we don't. We have one connection pool for each connection string. There's also this issue, which I think we should address.

Ladicek avatar Mar 20 '24 11:03 Ladicek

Done in #456 / #457

Ladicek avatar Jul 25 '24 10:07 Ladicek