fix fob bad log messages in rdbSave (#9842) (#9843)

logs message prints wrong file is failed to open temporary file
logs have error occurred in getcwd (uses same errno to report error)

Co-authored-by: Pavel Melkozerov <pavel.melkozerov@nokia.com>
This commit is contained in:
Pavel Melkozerov 2021-11-24 17:01:39 +03:00 committed by GitHub
parent 4512905961
commit 9630ded313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -292,6 +292,7 @@ int startAppendOnly(void) {
newfd = open(server.aof_filename,O_WRONLY|O_APPEND|O_CREAT,0644);
serverAssert(server.aof_state == AOF_OFF);
if (newfd == -1) {
char *str_err = strerror(errno);
char *cwdp = getcwd(cwd,MAXPATHLEN);
serverLog(LL_WARNING,
@ -299,7 +300,7 @@ int startAppendOnly(void) {
"append only file %s (in server root dir %s): %s",
server.aof_filename,
cwdp ? cwdp : "unknown",
strerror(errno));
str_err);
return C_ERR;
}
if (hasActiveChildProcess() && server.child_type != CHILD_TYPE_AOF) {

View File

@ -1372,13 +1372,14 @@ int rdbSave(char *filename, rdbSaveInfo *rsi) {
snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid());
fp = fopen(tmpfile,"w");
if (!fp) {
char *str_err = strerror(errno);
char *cwdp = getcwd(cwd,MAXPATHLEN);
serverLog(LL_WARNING,
"Failed opening the RDB file %s (in server root dir %s) "
"Failed opening the temp RDB file %s (in server root dir %s) "
"for saving: %s",
filename,
tmpfile,
cwdp ? cwdp : "unknown",
strerror(errno));
str_err);
return C_ERR;
}
@ -1402,6 +1403,7 @@ int rdbSave(char *filename, rdbSaveInfo *rsi) {
/* Use RENAME to make sure the DB file is changed atomically only
* if the generate DB file is ok. */
if (rename(tmpfile,filename) == -1) {
char *str_err = strerror(errno);
char *cwdp = getcwd(cwd,MAXPATHLEN);
serverLog(LL_WARNING,
"Error moving temp DB file %s on the final "
@ -1409,7 +1411,7 @@ int rdbSave(char *filename, rdbSaveInfo *rsi) {
tmpfile,
filename,
cwdp ? cwdp : "unknown",
strerror(errno));
str_err);
unlink(tmpfile);
stopSaving(0);
return C_ERR;