From cb961d8c8e10ff3b619f1579a03336a15e9e6f45 Mon Sep 17 00:00:00 2001 From: Huang Zhw Date: Sun, 11 Jul 2021 18:00:17 +0800 Subject: [PATCH] Do not install a file event to send data to rewrite child when parent stop sending diff to child in aof rewrite. (#8767) In aof rewrite, when parent stop sending data to child, if there is new rewrite data, aofChildWriteDiffData write event will be installed. Then this event is issued and deletes the file event without do anyting. This will happen over and over again until aof rewrite finish. This bug used to waste a few system calls per excessive wake-up (epoll_ctl and epoll_wait) per cycle, each cycle triggered by receiving a write command from a client. --- src/aof.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/aof.c b/src/aof.c index 30474b67d..b648509b7 100644 --- a/src/aof.c +++ b/src/aof.c @@ -187,7 +187,9 @@ void aofRewriteBufferAppend(unsigned char *s, unsigned long len) { /* Install a file event to send data to the rewrite child if there is * not one already. */ - if (aeGetFileEvents(server.el,server.aof_pipe_write_data_to_child) == 0) { + if (!server.aof_stop_sending_diff && + aeGetFileEvents(server.el,server.aof_pipe_write_data_to_child) == 0) + { aeCreateFileEvent(server.el, server.aof_pipe_write_data_to_child, AE_WRITABLE, aofChildWriteDiffData, NULL); }