diff options
author | zhaozhao.zz <276441700@qq.com> | 2022-06-02 19:03:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 14:03:47 +0300 |
commit | a18c91d6423777dffd6afca80d32bf1964f449e6 (patch) | |
tree | e0843f55d77639ace3a10a7fd3e090f9ac62defa /src/config.c | |
parent | aae0ec255327e431221f3946b953321246fc8a3b (diff) | |
download | redis-a18c91d6423777dffd6afca80d32bf1964f449e6.tar.gz |
rewrite alias config to original name (#10811)
Redis 7 adds some new alias config like `hash-max-listpack-entries` alias `hash-max-ziplist-entries`.
If a config file contains both real name and alias like this:
```
hash-max-listpack-entries 20
hash-max-ziplist-entries 20
```
after set `hash-max-listpack-entries` to 100 and `config rewrite`, the config file becomes to:
```
hash-max-listpack-entries 100
hash-max-ziplist-entries 20
```
we can see that the alias config is not modified, and users will get wrong config after restart.
6.0 and 6.2 doesn't have this bug, since they only have the `slave` word alias.
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/config.c b/src/config.c index 9856af3c0..c714b1994 100644 --- a/src/config.c +++ b/src/config.c @@ -1171,18 +1171,13 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) { * Append the line and populate the option -> line numbers map. */ rewriteConfigAppendLine(state,line); - /* Translate options using the word "slave" to the corresponding name - * "replica", before adding such option to the config name -> lines - * mapping. */ - char *p = strstr(argv[0],"slave"); - if (p) { - sds alt = sdsempty(); - alt = sdscatlen(alt,argv[0],p-argv[0]); - alt = sdscatlen(alt,"replica",7); - alt = sdscatlen(alt,p+5,strlen(p+5)); + /* If this is a alias config, replace it with the original name. */ + standardConfig *s_conf = lookupConfig(argv[0]); + if (s_conf && s_conf->flags & ALIAS_CONFIG) { sdsfree(argv[0]); - argv[0] = alt; + argv[0] = sdsnew(s_conf->alias); } + /* If this is sentinel config, we use sentinel "sentinel <config>" as option to avoid messing up the sequence. */ if (server.sentinel_mode && argc > 1 && !strcasecmp(argv[0],"sentinel")) { |