Always set server.aof_last_write_errno in aof write error (#10917)

The `can_log` variable prevents us from outputting too
many error logs. But it should not include the modification
of server.aof_last_write_errno.

We are doing this because:
1. In the short write case, we always set aof_last_write_errno
to ENOSPC, we don't care the `can_log` flag.

2. And we always set aof_last_write_status to C_ERR in aof write
error (except for FSYNC_ALWAYS, we exit). So there may be a chance
that `aof_last_write_errno` is not right.

An innocent bug or just a code cleanup.
This commit is contained in:
Binbin 2022-07-03 13:34:39 +08:00 committed by GitHub
parent 35e836c26d
commit 2ab6767744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1132,8 +1132,8 @@ void flushAppendOnlyFile(int force) {
if (can_log) { if (can_log) {
serverLog(LL_WARNING,"Error writing to the AOF file: %s", serverLog(LL_WARNING,"Error writing to the AOF file: %s",
strerror(errno)); strerror(errno));
server.aof_last_write_errno = errno;
} }
server.aof_last_write_errno = errno;
} else { } else {
if (can_log) { if (can_log) {
serverLog(LL_WARNING,"Short write while writing to " serverLog(LL_WARNING,"Short write while writing to "