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

[NEW]Add a command to get the number of replicas. #10852

Closed
ncghost1 opened this issue Jun 12, 2022 · 4 comments
Closed

[NEW]Add a command to get the number of replicas. #10852

ncghost1 opened this issue Jun 12, 2022 · 4 comments
Labels
state:to-be-closed requesting the core team to close the issue

Comments

@ncghost1
Copy link
Contributor

ncghost1 commented Jun 12, 2022

The problem/use-case that the feature addresses
When I want to use the wait command in my code, I want the numreplica to be equal to the number of all replicas,but redis does not provide a command that can return the number of replicas.If my timeout is 0 and numreplicas exceed the actual number, it will be blocked forever.

Currently, we can only use the info command to see connected_ Slaves: (number), but the code has no eyes. I can only let the code do a series of string operations to get it, which makes the code more complex and increases the code execution time.(Or is there another way to get it? Please let me know if there is a better way)

I think redis needs to provide a command to return the number of replicas. This is to provide a reference for the numreplicas parameter of the wait command and other purposes.

Description of the feature
A command that returns the number of slave nodes connected to the current master node,maybe we can call it numofreplicas.

@oranagra
Copy link
Member

seems related to #8684
The problem is that it could be that some replicas got disconnected, and then you won't wait for them.
Indicating that the number of replicas to wait for depends on the configuration, and not the current state.

@ncghost1
Copy link
Contributor Author

@oranagra
Adding this new command for the numreplica of the wait command is what I personally want at present, of course support all and other representatives numreplicas is better to use wait command.
Thank you for telling me the problem about using wait.

Put the wait command aside. Let's discuss the new command. Is it feasible to add this new command for future needs? For example, for some possible commands in the future that require the numreplicas parameter, it is indeed possible to add the optional parameter all to them, but sometimes we may not need all, we may only need half, one third, and so on.So if we can get the number of replicas, we can use them flexibly according to our own needs.

@oranagra
Copy link
Member

@ncghost1 it is unlikely that we'll add a dedicated command just to get that specific piece of info.
we have the INFO command for such things.
same as the ROLE command that we have now, which i'm guessing is obsolete.
I don't understand what you mean by but the code has no eyes.
maybe it would be easier for you see see the length of the array returned by ROLE.

@oranagra oranagra added the state:to-be-closed requesting the core team to close the issue label Jun 12, 2022
@ncghost1
Copy link
Contributor Author

but the code has no eyes

This means that we can use our eyes to get the information in the INFO command, but in the code implementation, it need to match and split the string to get specific information.

Thank you for your suggestion. I will try to use ROLE.

Then I will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:to-be-closed requesting the core team to close the issue
Projects
None yet
Development

No branches or pull requests

2 participants