fix: resolve timeout and performance issues in buffer write mode and AOF writes

- resolve timeout issue after small-batch writes in buffer mode
- address high disk usage and write bottleneck caused by forced AOF file sync
This commit is contained in:
饶乐佳 2024-11-29 14:20:19 +08:00 committed by suxb201
parent 3f253b327e
commit b7412933ea
2 changed files with 3 additions and 7 deletions

View File

@ -204,9 +204,6 @@ func (r *Redis) SendBytesBuff(buf []byte) {
}
func (r *Redis) flushBuff() {
if atomic.AddUint64(&r.sendCount, 1)%100 != 0 {
return
}
if !r.timer.Stop() {
select {
case <-r.timer.C:
@ -214,6 +211,9 @@ func (r *Redis) flushBuff() {
}
}
r.timer.Reset(time.Second)
if atomic.AddUint64(&r.sendCount, 1)%100 != 0 {
return
}
r.flush()
}

View File

@ -50,10 +50,6 @@ func (w *AOFWriter) Write(buf []byte) {
w.Close()
w.openFile(w.offset)
}
err = w.file.Sync()
if err != nil {
log.Panicf(err.Error())
}
}
func (w *AOFWriter) Close() {