diff options
author | Wang Yuan <wangyuan21@baidu.com> | 2021-04-01 17:45:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-01 12:45:15 +0300 |
commit | 1eb85249e7e9dafe4fbd023771e53c9a804c0a2f (patch) | |
tree | 5150655a954aadea8503f6b571126aba4f51d42b /src/bio.c | |
parent | 44d8b039e81d3088b5c69d586a7d0b6e9ffc5b1b (diff) | |
download | redis-1eb85249e7e9dafe4fbd023771e53c9a804c0a2f.tar.gz |
Handle remaining fsync errors (#8419)
In `aof.c`, we call fsync when stop aof, and now print a log to let user know that if fail.
In `cluster.c`, we now return error, the calling function already handles these write errors.
In `redis-cli.c`, users hope to save rdb, we now print a message if fsync failed.
In `rio.c`, we now treat fsync errors like we do for write errors.
In `server.c`, we try to fsync aof file when shutdown redis, we only can print one log if fail.
In `bio.c`, if failing to fsync aof file, we will set `aof_bio_fsync_status` to error , and reject writing just like last writing aof error, moreover also set INFO command field `aof_last_write_status` to error.
Diffstat (limited to 'src/bio.c')
-rw-r--r-- | src/bio.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -220,7 +220,17 @@ void *bioProcessBackgroundJobs(void *arg) { if (type == BIO_CLOSE_FILE) { close(job->fd); } else if (type == BIO_AOF_FSYNC) { - redis_fsync(job->fd); + if (redis_fsync(job->fd) == -1) { + int last_status; + atomicGet(server.aof_bio_fsync_status,last_status); + atomicSet(server.aof_bio_fsync_status,C_ERR); + if (last_status == C_OK) { + serverLog(LL_WARNING, + "Fail to fsync the AOF file: %s",strerror(errno)); + } + } else { + atomicSet(server.aof_bio_fsync_status,C_OK); + } } else if (type == BIO_LAZY_FREE) { job->free_fn(job->free_args); } else { |