I’m stuck on Replication - 13.
I have trouble understanding the logs. According to my understanding, the master is started by the tester at port 6379, and my code is the replica, which is the runner at port 6380. This works well, and even the RDB file exchange occurs without hiccups.
Then, the tester (master) tried to write to port 48586
, which resulted in a broken pipe
error. I can’t understand what this port has to do with this test and how it relates to my implementation.
Here are my logs:
[replication-13] Running tests for Replication > Stage #13: Command Processing
[replication-13] Master is running on port 6379
[replication-13] $ ./spawn_redis_server.sh --port 6380 --replicaof "localhost 6379"
[replication-13] master: Waiting for replica to initiate handshake with "PING" command
[replication-13] master: Received bytes: "*1\r\n$4\r\nPING\r\n"
[replication-13] master: Received RESP value: ["PING"]
[replication-13] Received ["PING"]
[replication-13] master: Sent "PONG"
[replication-13] master: Sent bytes: "+PONG\r\n"
[replication-13] master: Waiting for replica to send "REPLCONF listening-port 6380" command
[replication-13] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"
[replication-13] master: Received RESP value: ["REPLCONF", "listening-port", "6380"]
[replication-13] Received ["REPLCONF", "listening-port", "6380"]
[replication-13] master: Sent "OK"
[replication-13] master: Sent bytes: "+OK\r\n"
[replication-13] master: Waiting for replica to send "REPLCONF capa" command
[replication-13] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[replication-13] master: Received RESP value: ["REPLCONF", "capa", "psync2"]
[replication-13] Received ["REPLCONF", "capa", "psync2"]
[replication-13] master: Sent "OK"
[replication-13] master: Sent bytes: "+OK\r\n"
[replication-13] master: Waiting for replica to send "PSYNC" command
[replication-13] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[replication-13] master: Received RESP value: ["PSYNC", "?", "-1"]
[replication-13] Received ["PSYNC", "?", "-1"]
[replication-13] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"
[replication-13] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"
[replication-13] Sending RDB file...
[replication-13] master: Sent bytes: "$88\r\nREDIS0011\xfa\tredis-ver\x057.2.0\xfa\nredis-bits\xc0@\xfa\x05ctime\xc2m\b\xbce\xfa\bused-mem°\xc4\x10\x00\xfa\baof-base\xc0\x00\xff\xf0n;\xfe\xc0\xffZ\xa2"
[replication-13] Sent RDB file.
[your_program] RDB File content: $88
[your_program] REDIS0011� redis-ver7.2.0�
[your_program] redis-bits�@�ctime��eused-mem°�aof-base���n;���Z�
[replication-13] master: $ redis-cli SET foo 123
[replication-13] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[replication-13] master: $ redis-cli SET bar 456
[replication-13] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n"
[replication-13] write tcp [::1]:6379->[::1]:48586: write: broken pipe
[replication-13] Test failed
[replication-13] Terminating program
[your_program] Accepted connection from [::1]:52078
[your_program] Error reading: EOF
[replication-13] Program terminated successfully
View our article on debugging test failures: https://codecrafters.io/debug