ignore slaveof no one in redis.conf#7842
Conversation
|
no one ever said that the config file supports this, but you're right that someone may try to do that by mistake. |
|
OK,as long as it can avoid redis trying to connect to no:0.😃 |
|
So do you wanna do that (change the PR)? |
|
Do you mean submitting another PR or directly changing the current PR?(sorry,i'm not experienced in submitting pull requests😞) |
|
You can push another commit into the same branch, or amend the commit and |
|
Looks like CONFIG REWRITE is generating such a config, and changing that is wrong since there are already many config like that out there. |
|
So,we're gonna revert to the previous fix? |
|
How about checking if the port is either "one" (I.e "no one") or "0" (I.e. "127.0.0.1 0") , skip the config like your original fix, but anything else that failed the |
|
I think if the port is "0",we'll set it to |
|
I think the current (old) behaviour which sets masterhost to non-NULL when getting "127.0.0.1 0" is wrong. Come to think of it, explicitly setting to NULL is better, since it might override a previous statement in the config file, so override is better than skipping. |
|
So,we are going to skip "slaveof no one" and "slaveof 127.0.0.1 0" and set |
|
Sounds like a good plan. |
|
Just setting |
|
It seems that we can't set |
|
i'm sorry, i didn't dig deep enough to see the reason for the previous failure and assumed CONFIG REWRITE generates "127.0.0.1 0" when there's no master. # Prevent the slave from receiving master updates, and at
# the same time send a new script several times to the
# master, so that we'll end with EVALSHA into the backlog.
$R($slave_id) slaveof 127.0.0.1 0
$R($master_id) EVALSHA e6e0b547500efcec21eddb619ac3724081afee89 0
$R($master_id) EVALSHA e6e0b547500efcec21eddb619ac3724081afee89 0
$R($master_id) EVALSHA e6e0b547500efcec21eddb619ac3724081afee89 0
catch {
$R($slave_id) config rewrite
restart_server [expr {0-$slave_id}] true
set R($slave_id) [srv [expr {0-$slave_id}] client]
}so since 0 is a now a valid port number, i would like to suggest the following
|
|
I looked at the code for setting the port and found that the author did not verify whether the port is a valid number, but only verified whether the port is between 0 and 65535. Maybe we can maintain a consistent style with it. What do you think? |
|
@CaoZB what do you mean by that? |
|
I mean |
|
isn't that exactly what i suggested in my 1,2,3 above? |
|
@oranagra Updated,please review it. |
oranagra
left a comment
There was a problem hiding this comment.
let me know if the change i suggested seem good to you
|
LGTM😄 |
|
@CaoZB sorry for the ping-pong, please have another looks at my last two commits. |
|
😄I didn't even notice the memory leak.👍 |
|
Thank you for your precious time very much.😄 |
when slaveof config is "no one", reset any pre-existing config and resume. also solve a memory leak if slaveof appears twice. and fail loading if port number is out of range or not an integer. Co-authored-by: caozhengbin <[email protected]> Co-authored-by: Oran Agra <[email protected]> (cherry picked from commit a295770)
when slaveof config is "no one", reset any pre-existing config and resume. also solve a memory leak if slaveof appears twice. and fail loading if port number is out of range or not an integer. Co-authored-by: caozhengbin <[email protected]> Co-authored-by: Oran Agra <[email protected]>
when slaveof config is "no one", reset any pre-existing config and resume. also solve a memory leak if slaveof appears twice. and fail loading if port number is out of range or not an integer. Co-authored-by: caozhengbin <[email protected]> Co-authored-by: Oran Agra <[email protected]> (cherry picked from commit a295770)
I configure slaveof no one in redis.conf by accident,and redis tried to connect to no:0.I think that's not what i expected.