-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use before assignment of asyncDedicatedConnection in LettuceConnection #2984
Comments
This is a bug, good catch. We need to apply the database selection clearly on the newly created connection. Do you want to submit a pull request? |
Please do it if you have time :-) |
When new connection is created in doGetAsyncDedicatedConnection(), it is not yet assigned to asyncDedicatedConnection attribute, so it cannot be used in potentiallySelectDatabase() call. Fix this by passing the connection to the method. Closes spring-projects#2984 Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
Turns out the logic is broken here. I am not able to tell the difference between |
When new connection is created in doGetAsyncDedicatedConnection(), it is not yet assigned to asyncDedicatedConnection attribute, so it cannot be used in potentiallySelectDatabase() call. It seems that the select call is superfluous anyway here, because the `select()` method call can be made only when the cached dedicated connection is used (not a shared one) and the `select()` method always selects the database immediately on the cached dedicated connection. Therefore it should never be necessary to call select on newly created dedicated connection, because it is either created by `select()` method call or a default database is used. Closes spring-projects#2984 Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
Please check oldium@e47545a for possible fix. As I said, I am not sure whether the |
We now select the database on the dedicated connection. Previously, this call never happened on the dedicated connection and the only way a database could be selected is through the ConnectionFactory configuration. Closes #2984
@christophstrobl I do not think the fix is correct and the change to the test proves it. The |
thanks for the heads up - true - working on it. |
You're right, we're setting now the database index twice. We had initially a different understanding. By removing the database index customization check and db selection in |
I found issue while reading how Lettuce integration works in this method:
spring-data-redis/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java
Lines 966 to 975 in 777f079
The method creates a new connection, which is stored by the caller into a
asyncDedicatedConnection
attribute:spring-data-redis/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java
Lines 1026 to 1033 in 777f079
But it looks like the
asyncDedicatedConnection
is used before assignment inpotentiallySelectDatabase()
called bydoGetAsyncDedicatedConnection()
:spring-data-redis/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java
Lines 1068 to 1073 in 777f079
The text was updated successfully, but these errors were encountered: