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

Consider master-link-status state when selecting slaves #1439

Open
rhl-jfm opened this issue Mar 4, 2024 · 0 comments
Open

Consider master-link-status state when selecting slaves #1439

rhl-jfm opened this issue Mar 4, 2024 · 0 comments
Labels

Comments

@rhl-jfm
Copy link
Contributor

rhl-jfm commented Mar 4, 2024

Describe the bug
When a slave server in a Sentinel setup is restarted, the s_down flag for the server is cleared before the server is ready to serve requests. While loading or syncronizing data, the master-link-status for the server returns 'err'. Once the slave is fully synchronized and available, the master-link-status switches to 'ok'.

Currently predis only looks at the server flags ($slave[9]), which is not sufficient.

To Reproduce
Steps to reproduce the behavior:

  1. Restart a server in a Sentinel cluster. If the database contains a lot of data and is configured to use an AOF file, this will require a full resync with the master, which will take some time.
  2. Connect to the Sentinel cluster using predis while the server is syncing and perform a read query. This is likely to return a "LOADING Redis is loading the dataset in memory" response.

Expected behavior
The slave should not be selected before it is ready to serve data. The read query should not fail with a "LOADING" response.

Versions (please complete the following information):

  • Predis: 1.x, 2.x
  • PHP 8.1 (does not matter)
  • Redis Server 7.2.4 (I don't think is matters)
  • OS Ubuntu 22.04

Code sample
If applicable, a small snippet of code that reproduces the issue.

Additional context
Same issue as bug #542.

I'll create a pull request to make predis filter out slaves based on the master-link-status state.

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

No branches or pull requests

1 participant