bug fix: FlushDB command is not recorded by AOF (#142)

* bug fix: FlushDB command is not recorded by AOF

* bug fix: Fix an error occurred while rewriting aof rename, windows.ERROR_SHARING_VIOLATION

* bug fix: Fix an error occurred while rewriting aof rename, windows.ERROR_SHARING_VIOLATION

* change the flushDB procedures

* The savecmdline flushdb in the method is incorrectly selected, causing the testof error
This commit is contained in:
no sugar
2023-03-19 17:36:56 +08:00
committed by GitHub
parent 2bf829af1a
commit 11c0385241
2 changed files with 11 additions and 3 deletions

View File

@@ -142,7 +142,7 @@ func (server *Server) Exec(c redis.Connection, cmdLine [][]byte) (result redis.R
if c.InMultiState() {
return protocol.MakeErrReply("ERR command 'FlushDB' cannot be used in MULTI")
}
return server.flushDB(c.GetDBIndex())
return server.execFlushDB(c.GetDBIndex())
} else if cmdName == "save" {
return SaveRDB(server, cmdLine[1:])
} else if cmdName == "bgsave" {
@@ -203,6 +203,13 @@ func execSelect(c redis.Connection, mdb *Server, args [][]byte) redis.Reply {
return protocol.MakeOkReply()
}
func (server *Server) execFlushDB(dbIndex int) redis.Reply {
if server.persister != nil {
server.persister.SaveCmdLine(dbIndex, utils.ToCmdLine("FlushDB"))
}
return server.flushDB(dbIndex)
}
func (server *Server) flushDB(dbIndex int) redis.Reply {
if dbIndex >= len(server.dbSet) || dbIndex < 0 {
return protocol.MakeErrReply("ERR DB index is out of range")