From dd760bd5e6bc742932d4177d7cd691c0f195aa70 Mon Sep 17 00:00:00 2001 From: WuYunlong Date: Sat, 21 Jul 2018 08:48:51 +0800 Subject: [PATCH] Consider aof write error as well as rdb in lua script. --- src/scripting.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/scripting.c b/src/scripting.c index 328e3d681..23ff96c53 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -493,11 +493,21 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { { luaPushError(lua, shared.roslaveerr->ptr); goto cleanup; - } else if (server.stop_writes_on_bgsave_err && - server.saveparamslen > 0 && - server.lastbgsave_status == C_ERR) + } else if ((server.stop_writes_on_bgsave_err && + server.saveparamslen > 0 && + server.lastbgsave_status == C_ERR) || + (server.aof_state != AOF_OFF && + server.aof_last_write_status == C_ERR)) { - luaPushError(lua, shared.bgsaveerr->ptr); + if (server.aof_last_write_status == C_OK) { + luaPushError(lua, shared.bgsaveerr->ptr); + } else { + sds aof_write_err = sdscatfmt(sdsempty(), + "-MISCONF Errors writing to the AOF file: %s\r\n", + strerror(server.aof_last_write_errno)); + luaPushError(lua, aof_write_err); + sdsfree(aof_write_err); + } goto cleanup; } }