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

[GROW-3361] always release, instead of disconnect, when error occurs during get_connection #11

Merged
merged 3 commits into from
Aug 24, 2023

Conversation

zach-iee
Copy link

@zach-iee zach-iee commented Aug 21, 2023

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

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, but get_connection is neither of those

additional changes:

@zach-iee zach-iee self-assigned this Aug 21, 2023
@zach-iee zach-iee force-pushed the zach/release_connection_on_exception branch 2 times, most recently from cbea68a to e2bc9cb Compare August 21, 2023 15:30
@zach-iee zach-iee force-pushed the zach/release_connection_on_exception branch 2 times, most recently from 3744581 to 021fa98 Compare August 21, 2023 15:44
@zach-iee zach-iee force-pushed the zach/release_connection_on_exception branch from 021fa98 to 71677a5 Compare August 21, 2023 15:45
@codecov-commenter
Copy link

codecov-commenter commented Aug 21, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.03% ⚠️

Comparison is base (ae88892) 92.37% compared to head (fa3864f) 92.35%.

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     
Files Changed Coverage Δ
redis/cluster.py 90.89% <100.00%> (+0.03%) ⬆️
redis/retry.py 100.00% <100.00%> (ø)
tests/test_cluster.py 96.90% <100.00%> (-0.16%) ⬇️
tests/test_retry.py 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zach-iee zach-iee requested a review from bellatoris August 22, 2023 01:16
@zach-iee zach-iee changed the title always release, instead of disconnect, when error occurs during get_connection [GROW-3361] always release, instead of disconnect, when error occurs during get_connection Aug 22, 2023
@bellatoris bellatoris requested a review from neoatlan August 23, 2023 01:28
@@ -2163,6 +2162,8 @@ def _send_cluster_commands(
if n.connection:
n.connection.disconnect()
n.connection_pool.release(n.connection)
if len(nodes) > 0:

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?

Copy link
Author

@zach-iee zach-iee Aug 23, 2023

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

@zach-iee zach-iee requested a review from neoatlan August 23, 2023 05:53
@zach-iee zach-iee merged commit 179891d into master Aug 24, 2023
@zach-iee zach-iee deleted the zach/release_connection_on_exception branch August 24, 2023 01:56
zach-iee added a commit that referenced this pull request Aug 24, 2023
…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

(cherry picked from commit 179891d)
zach-iee added a commit that referenced this pull request Aug 24, 2023
…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

(cherry picked from commit 179891d)
zach-iee added a commit that referenced this pull request Sep 14, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants