I’m stuck on Stage #YG4
I believe I am facing some race conditions when sending the commands to the replicas, but I am having a hard time to understand where’s the problem.
Here are my logs:
tester::#HD5] [handshake] Received "FULLRESYNC b8b6e5ee4a5e6b1628df86d459349fd4acbbbe37 0"
[tester::#HD5] [handshake] Reading RDB file...
[your_program] << $88
[your_program] REDIS0011� redis-ver7.2.0�
[your_program] redis-bits�@�ctime��eused-mem°�aof-base���n;���Z�
[your_program] push
[tester::#HD5] [handshake] replica-3: Received 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"
[tester::#HD5] [handshake] Received RDB file
[tester::#HD5] [test] client: $ redis-cli SET foo 123
[tester::#HD5] [test] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[your_program] >> "*3 $3 SET $3 foo $3 123"
[your_program] <<[fwd][127.0.0.1:45902] "*3 $3 SET $3 foo $3 123"
[your_program] <<[fwd][127.0.0.1:45908] "*3 $3 SET $3 foo $3 123"
[your_program] <<[fwd][127.0.0.1:45912] "*3 $3 SET $3 foo $3 123"
[your_program] << "+OK "
[tester::#HD5] [test] client: Received bytes: "+OK\r\n"
[tester::#HD5] [test] client: Received RESP simple string: "OK"
[tester::#HD5] [test] Received "OK"
[tester::#HD5] [test] client: > SET bar 456
[tester::#HD5] [test] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n"
[your_program] >> "*3 $3 SET $3 bar $3 456"
[your_program] <<[fwd][127.0.0.1:45902] "*3 $3 SET $3 bar $3 456"
[your_program] <<[fwd][127.0.0.1:45908] "*3 $3 SET $3 bar $3 456"
[your_program] <<[fwd][127.0.0.1:45912] "*3 $3 SET $3 bar $3 456"
[your_program] << "+OK "
[tester::#HD5] [test] client: Received bytes: "+OK\r\n"
[tester::#HD5] [test] client: Received RESP simple string: "OK"
[tester::#HD5] [test] Received "OK"
[tester::#HD5] [test] client: > SET baz 789
[tester::#HD5] [test] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
[your_program] >> "*3 $3 SET $3 baz $3 789"
[your_program] <<[fwd][127.0.0.1:45902] "*3 $3 SET $3 baz $3 789"
[your_program] <<[fwd][127.0.0.1:45908] "*3 $3 SET $3 baz $3 789"
[your_program] <<[fwd][127.0.0.1:45912] "*3 $3 SET $3 baz $3 789"
[your_program] << "+OK "
[tester::#HD5] [test] client: Received bytes: "+OK\r\n"
[tester::#HD5] [test] client: Received RESP simple string: "OK"
[tester::#HD5] [test] Received "OK"
[tester::#HD5] [test] Testing Replica: 1/3
[tester::#HD5] [test] replica-1: Expecting "SET foo 123" to be propagated
[tester::#HD5] Received: "ET\r\n$3\r\nfoo\r\n$3\r\n123*3\r\n$3\r\nSE"
[tester::#HD5] ^ error
[tester::#HD5] Error: Expected \r\n after 3 bytes of data in bulk string
[tester::#HD5] Test failed
[tester::#HD5] Terminating program
[tester::#HD5] Program terminated successfully
And here’s a snippet of my code: