https://github.com/antirez/redis/blob/3519a5a026be50022fb4e103ddc602ffd59daf42/src/connection.c#L217
Issue from code review.
If conn->flags & CONN_FLAG_WRITE_BARRIER ==1, because in function aeCreateFileEvent aeCreateFileEvent(server.el,conn->fd,AE_WRITABLE,conn->type->ae_handler,conn) it just register file event with flag AE_WRITABLE, and the CONN_FLAG_WRITE_BARRIER doesn't work. So the write barrier can't work in function aeProcessEvents.
Comment From: antirez
Thanks @woodliu, pinging the maintainer of this code, @yossigo. Thank you both.
Comment From: woodliu
May be CONN_FLAG_WRITE_BARRIER for socket event, not for file event?
Comment From: oranagra
@woodliu thanks for reaching out. connection.c implements the barrier on its own (in connSocketEventHandler), and doesn't rely on the barrier implementation of ae.c.
that's one of the reasons it has a different flag (CONN_FLAG_WRITE_BARRIER vs AE_BARRIER), which is in fact internal, the API only exposes a bool (int barrier) to the "user".
i admit that this is a little bit confusing. redis no longer uses the barrier mechanism of ae.c, so leaving it there is confusing, but i suppose maybe some day it will be used.
let me know if i missed your point and you still see a bug.
Comment From: woodliu
@oranagra You are very kind! I am studying the redis code, the knowledge is very valuable!