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

connectionProvider.release() doesn't really discard the connection after connection invalidated. #3067

Open
Bughue opened this issue Dec 4, 2024 · 4 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@Bughue
Copy link

Bughue commented Dec 4, 2024

Inside validateConnection, called resetConnection(), and then called release(), but the action of release() does not necessarily discard the connection.

So, getNativeConnection() probably get a same channel(TCP) which is invalid.
We've actually tested this, and the result is that still get the same tcp connection after resetConnection many times.

image

image
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 4, 2024
@Bughue Bughue changed the title connectionProvider.release() doesn't really discard the connection after valididateConnection fails. connectionProvider.release() doesn't really discard the connection after connection invalid. Dec 4, 2024
@Bughue Bughue changed the title connectionProvider.release() doesn't really discard the connection after connection invalid. connectionProvider.release() doesn't really discard the connection after connection invalidated. Dec 4, 2024
@Bughue
Copy link
Author

Bughue commented Dec 6, 2024

somebody help

@mp911de
Copy link
Member

mp911de commented Dec 6, 2024

discardIfNecessary resets the Redis transaction state using Redi's DISCARD command. pool.returnObject(…) is what you're looking for. You need to configure pool object validation via GenericObjectPoolConfig.testOnBorrow to check for connected Redis connections.

probably get a same channel(TCP) which is invalid.

Care to elaborate what invalid means for you? In which state is the connection?

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Dec 6, 2024
@Bughue
Copy link
Author

Bughue commented Dec 10, 2024

discardIfNecessary resets the Redis transaction state using Redi's DISCARD command. pool.returnObject(…) is what you're looking for. You need to configure pool object validation via GenericObjectPoolConfig.testOnBorrow to check for connected Redis connections.

probably get a same channel(TCP) which is invalid.

Care to elaborate what invalid means for you? In which state is the connection?

async().discard() not invoked because redisConnection.isMuti()==false, so, connection will not be discarded and it will be return to pool.

channel invalid means connection.sync().ping() failed and throw a timeout exception.

configure pool object validation via GenericObjectPoolConfig.testOnBorrow to check for connected Redis connections

Maybe this is a way to go, I just assumed that since SharedConnection provided a validateConnection, that it should achieve a similar result, right? Because connection.sync().ping() did fail.

image

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 10, 2024
@mp911de mp911de self-assigned this Dec 16, 2024
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Dec 16, 2024
@mp911de
Copy link
Member

mp911de commented Dec 16, 2024

One idea could be introducing a validation function or a depth of validation. For this to work, the Lettuce driver would need to introduce a Predicate<T extends StatefulConnection> to ConnectionPoolSupport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants