-
Notifications
You must be signed in to change notification settings - Fork 0
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
[GROW-3361] always release, instead of disconnect, when error occurs during get_connection #11
Conversation
cbea68a
to
e2bc9cb
Compare
3744581
to
021fa98
Compare
…s in cluster pipeline
021fa98
to
71677a5
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #11 +/- ##
==========================================
- Coverage 92.37% 92.35% -0.03%
==========================================
Files 119 119
Lines 30638 30678 +40
==========================================
+ Hits 28302 28332 +30
- Misses 2336 2346 +10
☔ View full report in Codecov by Sentry. |
@@ -2163,6 +2162,8 @@ def _send_cluster_commands( | |||
if n.connection: | |||
n.connection.disconnect() | |||
n.connection_pool.release(n.connection) | |||
if len(nodes) > 0: |
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.
Just for curious, Is there any reason for delaying after the disconnect the connections?
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.
this code is a safety feature to catch all connection leaks, but it comes with a cost of disconnecting all connections used in this function. Ideally, this code block shouldn't be executed, but if executed due to an unknown error, it means that there probably is a problem with Soda or Redis. Reconnecting can put more load on a Redis node, so i thought static backoff could alleviate the load on Redis CPU
…during get_connection (#11) * add is_supported_error() to retry * release, instead of disconnect on any error, when fetching connections in cluster pipeline * add a default backoff after cluster pipeline disconnects its connections
Pull Request check-list
Please make sure to review and check all of these items:
$ tox
pass with this change (including linting)?NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Description of change
gevent.Timeout
used to cause a connection leak, but that was patched with #8.Now, i want to make sure that connections are not disconnected so often, so this PR makes any error from
get_connection
to always release a connection without disconnection. Disconnection is only necessary, when a connection is reading or writing, butget_connection
is neither of thoseadditional changes:
isinstance(e, self.retry._supported_errors)
is lengthy, so i've also created ais_supported_error
function to shorten the code