Skip to content

Fix: Prevent routing reads to Redis slave nodes in loading state #3370

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ofekshenawa
Copy link
Collaborator

Problem

When a new slave node is added to a Redis cluster, it enters a loading state while it synchronizes data from its master. If the client has ReadOnly=true enabled, it may route read operations to this loading slave node, which can result in nil values or errors being returned to the application.
closes #3222

Solution

This PR adds logic to detect when a slave node is in the loading state (by checking for LOADING errors) and temporarily excludes such nodes from the read distribution until they're ready to serve requests.

@ndyakov
Copy link
Member

ndyakov commented May 9, 2025

@ofekshenawa I am not sure (was not able to find information) if PING will return -LOADING errors. Let's think of a way to test this somehow? We will need to write tests for it anyway. Sure, we can mock the response and we will get the correct execution, but not sure on top of my head how to actually trigger a redis node to load the rdb for longer periods of time, so we can test. Any ideas?

@ndyakov
Copy link
Member

ndyakov commented May 9, 2025

Update: PING at the moment should return LOADING, but it may change. Keep that in mind. Let's think of a way to test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read nil from a new-joined slave node in Redis cluster.
2 participants