diff options
author | Oran Agra <oran@redislabs.com> | 2022-11-09 10:02:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 10:02:18 +0200 |
commit | ccaef5c923a14dc183c50530f52ada0fda012179 (patch) | |
tree | f8af010a6549d77db8d90465fbff65459a557d51 /tests/support | |
parent | f92899185367ab08a084c501ba54759390c92e63 (diff) | |
download | redis-ccaef5c923a14dc183c50530f52ada0fda012179.tar.gz |
diskless master, avoid bgsave child hung when fork parent crashes (#11463)
During a diskless sync, if the master main process crashes, the child would
have hung in `write`. This fix closes the read fd on the child side, so that if the
parent crashes, the child will get a write error and exit.
This change also fixes disk-based replication, BGSAVE and AOFRW.
In that case the child wouldn't have been hang, it would have just kept
running until done which may be pointless.
There is a certain degree of risk here. in case there's a BGSAVE child that could
maybe succeed and the parent dies for some reason, the old code would have let
the child keep running and maybe succeed and avoid data loss.
On the other hand, if the parent is restarted, it would have loaded an old rdb file
(or none), and then the child could reach the end and rename the rdb file (data
conflicting with what the parent has), or also have a race with another BGSAVE
child that the new parent started.
Note that i removed a comment saying a write error will be ignored in the child
and handled by the parent (this comment was very old and i don't think relevant).
Diffstat (limited to 'tests/support')
-rw-r--r-- | tests/support/util.tcl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 51a8420a3..a7332d29c 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -627,6 +627,14 @@ proc get_child_pid {idx} { return $child_pid } +proc process_is_alive pid { + if {[catch {exec ps -p $pid} err]} { + return 0 + } else { + return 1 + } +} + proc cmdrstat {cmd r} { if {[regexp "\r\ncmdstat_$cmd:(.*?)\r\n" [$r info commandstats] _ value]} { set _ $value |