While working on Replication section 18, I keep failing the tests. I previously passed stage 17, but as a part of my solution to stage 18, it now fails. When I logged out the errors, I kept getting this error: Connection reset by peer (os error 104)
, which I found less than useful.
My changes are almost entirely in perform_await, which sends a REPLCONF GETACK *
command to all replicas then reads the response. I have noticed that I do not get the error about resetting the connection if I don’t read the response from the replicas. That leads me to think that the error must be coming from how the test runner handles the streams. I have tested this locally, and, as far as I can tell, the behavior is identical to how Redis handles things (at least outwardly) for simple use cases.
I tested performed the following commands to test this (both against my own server and against the actual Redis server - i.e. replace cargo run
with redis-server
):
cargo run
in one terminalcargo run --port 6380 --replicaof 127.0.0.1 6379
in a second terminalcargo run --port 6381 --replicaof 127.0.0.1 6379
in a third terminalredis-cli set foo bar & redis-cli wait 5 1000 & wait
in a fourth terminalredis-cli set bar baz && redis-cli wait 5 1000
in the same terminal as above
EDIT: The replica stream handling function might also be relevant.