-
Notifications
You must be signed in to change notification settings - Fork 906
GODRIVER-3516 Fix the issue in getOrQueueForIdleConn where connectionPerished conn.… #2051
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
base: master
Are you sure you want to change the base?
Conversation
…isAlive involves network requests, which can cause the p.idleMu.Lock() when obtaining conn from the pool to be blocked for too long.
I think it is unnecessary to verify whether this conn is alive here, because even if the connection is alive when it is obtained, there is no guarantee that the conn will still be alive when it is passed to the caller. The connection may have been disconnected between these two steps. |
@prestonvasquez ping |
@linfeip Thank you for the contribution! Would you mind also removing the connection.IsAlive() method since it's no longer being used? Otherwise this LGTM. |
API Change ReportNo changes found! |
@prestonvasquez Alright, I have removed the unused method connection.isAlive() |
@@ -169,7 +169,7 @@ type reason struct { | |||
// connectionPerished checks if a given connection is perished and should be removed from the pool. | |||
func connectionPerished(conn *connection) (reason, bool) { | |||
switch { | |||
case conn.closed() || !conn.isAlive(): | |||
case conn.closed(): | |||
// A connection would only be closed if it encountered a network error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@linfeip, I appreciate your contribution! Would you mind updating the comment to match the changes? Otherwise, it looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qingyang-hu Alright, I've already updated the comments.
Is there a plan to backport to v1.17.x ? @qingyang-hu |
@limpo1989 This has been scheduled for the 2.2.2 and 1.17.4 patch releases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@linfeip, one more issue. Can you please remove the test case, "TestPool_checkOut/discards_connections_closed_by_the_server_side", at
t.Run("discards connections closed by the server side", func(t *testing.T) { |
@qingyang-hu I have removed the test cases that are no longer in use. |
GODRIVER-3516
…isAlive involves network requests, which can cause the p.idleMu.Lock() when obtaining conn from the pool to be blocked for too long.
Summary
the lock in
getOrQueueForIdleConn
will cause connection acquisition to block under high concurrency due to the IO request inc.nc.Read(b[:])
inside isAlive.Background & Motivation
Before modifying isAlive
After