sundb 694a869e78 Fix the timing of read and write events under kqueue (#9416)
Normally we execute the read event first and then the write event.
When the barrier is set, we will do it reverse.
However, under `kqueue`, if an `fd` has both read and write events,
reading the event using `kevent` will generate two events, which will
result in uncontrolled read and write timing.

This also means that the guarantees of AOF `appendfsync` = `always` are
not met on MacOS without this fix.

The main change to this pr is to cache the events already obtained when reading
them, so that if the same `fd` occurs again, only the mask in the cache is updated,
rather than a new event is generated.

This was exposed by the following test failure on MacOS:
```
*** [err]: AOF fsync always barrier issue in tests/integration/aof.tcl
Expected 544 != 544 (context: type eval line 26 cmd {assert {$size1 != $size2}} proc ::test)
```

(cherry picked from commit 306a5ccd2d053ff653988b61a779e3cbce408874)
2021-10-04 13:59:40 +03:00
..
2020-11-09 21:48:56 -08:00
2020-04-24 17:11:21 -07:00
2019-02-24 21:38:15 +01:00
2021-04-06 12:42:18 +03:00
2020-10-27 15:04:18 +02:00
2021-02-24 10:10:02 +02:00
2020-05-05 23:35:08 -04:00
2019-11-19 17:23:47 +08:00
2019-10-02 11:30:20 +02:00
2021-04-01 12:45:15 +03:00
2021-06-01 17:03:36 +03:00
2021-01-04 17:02:57 +02:00
2021-01-28 16:19:43 +02:00
2020-07-21 08:13:05 +03:00
2021-07-21 21:06:49 +03:00