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

[Redis-benchmark] Use IPs in the reply of CLUSTER NODES command #8154

Merged
merged 1 commit into from Dec 17, 2020

Conversation

ShooterIT
Copy link
Collaborator

If we only has one node in cluster or before 8fdc857, we don't know myself ip, so we should use config.hostip for myself.

But now, more than one node in cluster, if we use -h with virtual IP or DNS, benchmark doesn't show node real ip and port of myself even though it could get right IP and port by CLUSTER NODES command.

We must use sdsnew(ip) to update node->ip if it is different from config.hostip, because we will free ip when leave this function.
Here will free node->ip https://github.com/redis/redis/blob/unstable/src/redis-benchmark.c#L1084-L1088

Comment on lines +1185 to +1186
if (ip != NULL && strcmp(node->ip, ip) != 0) {
node->ip = sdsnew(ip);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShooterIT i'm not too familiar with this area, but noticed this PR was neglected and and i would like to promote, please help me with the review.

one thing that's odd to me is that in the past we used to enter this block only if node->ip is NULL, and now we proceed to do strcmp without even checking if if's NULL or not. so maybe we need another || here.

another thing i wanna note is that we need to aim for redis-benchmark to be able to work with both new and old redis servers, so it should still be compatible with the old behavior of CLUSTER NODES too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @oranagra the ip of firstNode is config.hostip, it never is NULL, redis-benchmark will core dump in the pas if it is NULL, because we double free this node->ip.
Old version before 8fdc857, we won't get myself ip, so we need to judge the ip parsed from CLUSTER NODE is empty or not

@oranagra oranagra merged commit 6413e5f into redis:unstable Dec 17, 2020
oddcc pushed a commit to oddcc/redis that referenced this pull request Dec 27, 2020
…edis#8154)

If we only has one node in cluster or before 8fdc857, we don't know myself ip, so we should use config.hostip for myself.
However, we should use the IP from the command response to update node->ip if it exists and is different from config.hostip

otherwise, when there's more than one node in cluster, if we use -h with virtual IP or DNS, benchmark doesn't show node real ip and port of myself even though it could get right IP and port by CLUSTER NODES command.
@oranagra oranagra added the release-notes indication that this issue needs to be mentioned in the release notes label Jan 10, 2021
@oranagra oranagra mentioned this pull request Jan 10, 2021
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Mar 2, 2021
…edis#8154)

If we only has one node in cluster or before 8fdc857, we don't know myself ip, so we should use config.hostip for myself.
However, we should use the IP from the command response to update node->ip if it exists and is different from config.hostip

otherwise, when there's more than one node in cluster, if we use -h with virtual IP or DNS, benchmark doesn't show node real ip and port of myself even though it could get right IP and port by CLUSTER NODES command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes indication that this issue needs to be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants