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

Fix sentinel mode read-write separation #749

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JackiLin
Copy link

@JackiLin JackiLin commented Sep 6, 2024

When I attempted to set up read-write separation in Sentinel mode by configuring redis://redis-master/db?is_master=0, I noticed that both read and write requests were still being directed to the master node, without any separation. After reviewing and debugging the source code, I found that the issue was due to redis-py being unable to correctly parse the is_master parameter, and there was also an error in how the project handled is_master. The pool.is_master was only set to False after retrieving the redis.sentinel.SentinelConnectionPool object from redis-py, which resulted in the system supposedly using the slave node, but actually using the master node.
image

Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.3%. Comparing base (f34935c) to head (df4fd4d).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
django_redis/pool.py 66.7% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #749     +/-   ##
========================================
- Coverage    63.3%   63.3%   -0.0%     
========================================
  Files          43      43             
  Lines        3215    3221      +6     
  Branches      244     244             
========================================
+ Hits         2034    2037      +3     
- Misses       1164    1167      +3     
  Partials       17      17             
Flag Coverage Δ
mypy 38.0% <17.7%> (-<0.1%) ⬇️
tests 90.3% <84.7%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

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.

1 participant