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
7f1c3607
Commit
7f1c3607
authored
Mar 24, 2014
by
Salvatore Sanfilippo
Browse files
Merge pull request #1606 from mattsta/fix-disk-full-dataloss
Fix data loss when save AOF/RDB with no free space
parents
906c4d77
42904551
Changes
3
Show whitespace changes
Inline
Side-by-side
src/aof.c
View file @
7f1c3607
...
@@ -969,9 +969,9 @@ int rewriteAppendOnlyFile(char *filename) {
...
@@ -969,9 +969,9 @@ int rewriteAppendOnlyFile(char *filename) {
}
}
/* Make sure data will not remain on the OS's output buffers */
/* Make sure data will not remain on the OS's output buffers */
fflush
(
fp
);
if
(
fflush
(
fp
)
==
EOF
)
goto
werr
;
aof_fsync
(
fileno
(
fp
));
if
(
aof_fsync
(
fileno
(
fp
))
==
-
1
)
goto
werr
;
fclose
(
fp
);
if
(
fclose
(
fp
)
==
EOF
)
goto
werr
;
/* Use RENAME to make sure the DB file is changed atomically only
/* Use RENAME to make sure the DB file is changed atomically only
* if the generate DB file is ok. */
* if the generate DB file is ok. */
...
...
src/rdb.c
View file @
7f1c3607
...
@@ -690,9 +690,9 @@ int rdbSave(char *filename) {
...
@@ -690,9 +690,9 @@ int rdbSave(char *filename) {
rioWrite
(
&
rdb
,
&
cksum
,
8
);
rioWrite
(
&
rdb
,
&
cksum
,
8
);
/* Make sure data will not remain on the OS's output buffers */
/* Make sure data will not remain on the OS's output buffers */
fflush
(
fp
);
if
(
fflush
(
fp
)
==
EOF
)
goto
werr
;
fsync
(
fileno
(
fp
));
if
(
fsync
(
fileno
(
fp
))
==
-
1
)
goto
werr
;
fclose
(
fp
);
if
(
fclose
(
fp
)
==
EOF
)
goto
werr
;
/* Use RENAME to make sure the DB file is changed atomically only
/* Use RENAME to make sure the DB file is changed atomically only
* if the generate DB file is ok. */
* if the generate DB file is ok. */
...
...
src/sentinel.c
View file @
7f1c3607
...
@@ -1562,19 +1562,22 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
...
@@ -1562,19 +1562,22 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
void
sentinelFlushConfig
(
void
)
{
void
sentinelFlushConfig
(
void
)
{
int
fd
;
int
fd
;
int
saved_hz
=
server
.
hz
;
int
saved_hz
=
server
.
hz
;
int
rewrite_status
;
server
.
hz
=
REDIS_DEFAULT_HZ
;
server
.
hz
=
REDIS_DEFAULT_HZ
;
if
(
rewriteConfig
(
server
.
configfile
)
!=
-
1
)
{
rewrite_status
=
rewriteConfig
(
server
.
configfile
);
/* Rewrite succeded, fsync it. */
if
((
fd
=
open
(
server
.
configfile
,
O_RDONLY
))
!=
-
1
)
{
fsync
(
fd
);
close
(
fd
);
}
}
else
{
redisLog
(
REDIS_WARNING
,
"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s"
,
strerror
(
errno
));
}
server
.
hz
=
saved_hz
;
server
.
hz
=
saved_hz
;
if
(
rewrite_status
==
-
1
)
goto
werr
;
if
((
fd
=
open
(
server
.
configfile
,
O_RDONLY
))
==
-
1
)
goto
werr
;
if
(
fsync
(
fd
)
==
-
1
)
goto
werr
;
if
(
close
(
fd
)
==
EOF
)
goto
werr
;
return
;
return
;
werr:
if
(
fd
!=
-
1
)
close
(
fd
);
redisLog
(
REDIS_WARNING
,
"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s"
,
strerror
(
errno
));
}
}
/* ====================== hiredis connection handling ======================= */
/* ====================== hiredis connection handling ======================= */
...
...
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