Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
65311a33
Unverified
Commit
65311a33
authored
Mar 29, 2021
by
Yossi Gottlieb
Committed by
GitHub
Mar 29, 2021
Browse files
Fix config rewrite with an empty "save" parameter. (#8719)
parent
315df9ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
65311a33
...
@@ -1381,14 +1381,19 @@ void rewriteConfigSaveOption(struct rewriteConfigState *state) {
...
@@ -1381,14 +1381,19 @@ void rewriteConfigSaveOption(struct rewriteConfigState *state) {
return
;
return
;
}
}
/* Note that if there are no save parameters at all, all the current
/* Rewrite save parameters, or an empty 'save ""' line to avoid the
* config line with "save" will be detected as orphaned and deleted,
* defaults from being used.
* resulting into no RDB persistence as expected. */
*/
for
(
j
=
0
;
j
<
server
.
saveparamslen
;
j
++
)
{
if
(
!
server
.
saveparamslen
)
{
line
=
sdscatprintf
(
sdsempty
(),
"save %ld %d"
,
rewriteConfigRewriteLine
(
state
,
"save"
,
sdsnew
(
"save
\"\"
"
),
0
);
(
long
)
server
.
saveparams
[
j
].
seconds
,
server
.
saveparams
[
j
].
changes
);
}
else
{
rewriteConfigRewriteLine
(
state
,
"save"
,
line
,
1
);
for
(
j
=
0
;
j
<
server
.
saveparamslen
;
j
++
)
{
line
=
sdscatprintf
(
sdsempty
(),
"save %ld %d"
,
(
long
)
server
.
saveparams
[
j
].
seconds
,
server
.
saveparams
[
j
].
changes
);
rewriteConfigRewriteLine
(
state
,
"save"
,
line
,
1
);
}
}
}
/* Mark "save" as processed in case server.saveparamslen is zero. */
/* Mark "save" as processed in case server.saveparamslen is zero. */
rewriteConfigMarkAsProcessed
(
state
,
"save"
);
rewriteConfigMarkAsProcessed
(
state
,
"save"
);
}
}
...
...
tests/unit/introspection.tcl
View file @
65311a33
...
@@ -180,6 +180,18 @@ start_server {tags {"introspection"}} {
...
@@ -180,6 +180,18 @@ start_server {tags {"introspection"}} {
}
}
}
}
test
{
CONFIG REWRITE handles save properly
}
{
r config set save
"3600 1 300 100 60 10000"
r config rewrite
restart_server 0 true false
assert_equal
[
r config get save
]
{
save
{
3600 1 300 100 60 10000
}}
r config set save
""
r config rewrite
restart_server 0 true false
assert_equal
[
r config get save
]
{
save
{}}
}
# Config file at this point is at a wierd state, and includes all
# Config file at this point is at a wierd state, and includes all
# known keywords. Might be a good idea to avoid adding tests here.
# known keywords. Might be a good idea to avoid adding tests here.
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment