I’m stuck on Stage #NA2 (Replication - WAIT with multiple commands)
I’ve successfully “passed the first WAIT test”, indicating that my SET method is working correctly. However, I’m encountering issues with the second SET command not returning an “OK” response to the tester client.
I’ve implemented the following functionality:
- Returning “numreplicas” of the slaves
- Returning acknowledgment or “timeout” if all slaves don’t respond
The test fails on the 2nd SET command, even though the first SET and WAIT commands were successful.
I’m unsure if this is due to an error in my implementation or if the test case might be checking results too quickly.
When I use println for debugging, I can see that the response is still being printed normally, but it appears after the error message: “Received: “” (no content received)”
Here are my logs:
[tester::#NA2] Running tests for Stage #NA2 (Replication - WAIT with multiple commands)
[tester::#NA2] $ ./spawn_redis_server.sh --port 6379
[tester::#NA2] Proceeding to create 4 replicas.
[tester::#NA2] Creating replica: 1
[tester::#NA2] replica-1: $ redis-cli PING
[tester::#NA2] replica-1: Sent bytes: "*1\r\n$4\r\nPING\r\n"
[tester::#NA2] replica-1: Received bytes: "+PONG\r\n"
[tester::#NA2] replica-1: Received RESP simple string: "PONG"
[tester::#NA2] Received "PONG"
[tester::#NA2] replica-1: > REPLCONF listening-port 6380
[tester::#NA2] replica-1: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"
[tester::#NA2] replica-1: Received bytes: "+OK\r\n"
[tester::#NA2] replica-1: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-1: > REPLCONF capa psync2
[tester::#NA2] replica-1: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[tester::#NA2] replica-1: Received bytes: "+OK\r\n"
[tester::#NA2] replica-1: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-1: > PSYNC ? -1
[tester::#NA2] replica-1: Sent bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[tester::#NA2] replica-1: Received bytes: "+FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0\r\n"
[tester::#NA2] replica-1: Received RESP simple string: "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Received "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Reading RDB file...
[tester::#NA2] replica-1: 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::#NA2] Received RDB file
[tester::#NA2] Creating replica: 2
[tester::#NA2] replica-2: $ redis-cli PING
[tester::#NA2] replica-2: Sent bytes: "*1\r\n$4\r\nPING\r\n"
[tester::#NA2] replica-2: Received bytes: "+PONG\r\n"
[tester::#NA2] replica-2: Received RESP simple string: "PONG"
[tester::#NA2] Received "PONG"
[tester::#NA2] replica-2: > REPLCONF listening-port 6381
[tester::#NA2] replica-2: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6381\r\n"
[tester::#NA2] replica-2: Received bytes: "+OK\r\n"
[tester::#NA2] replica-2: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-2: > REPLCONF capa psync2
[tester::#NA2] replica-2: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[tester::#NA2] replica-2: Received bytes: "+OK\r\n"
[tester::#NA2] replica-2: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-2: > PSYNC ? -1
[tester::#NA2] replica-2: Sent bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[tester::#NA2] replica-2: Received bytes: "+FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0\r\n"
[tester::#NA2] replica-2: Received RESP simple string: "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Received "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Reading RDB file...
[tester::#NA2] replica-2: 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::#NA2] Received RDB file
[tester::#NA2] Creating replica: 3
[tester::#NA2] replica-3: $ redis-cli PING
[tester::#NA2] replica-3: Sent bytes: "*1\r\n$4\r\nPING\r\n"
[tester::#NA2] replica-3: Received bytes: "+PONG\r\n"
[tester::#NA2] replica-3: Received RESP simple string: "PONG"
[tester::#NA2] Received "PONG"
[tester::#NA2] replica-3: > REPLCONF listening-port 6382
[tester::#NA2] replica-3: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6382\r\n"
[tester::#NA2] replica-3: Received bytes: "+OK\r\n"
[tester::#NA2] replica-3: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-3: > REPLCONF capa psync2
[tester::#NA2] replica-3: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[tester::#NA2] replica-3: Received bytes: "+OK\r\n"
[tester::#NA2] replica-3: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-3: > PSYNC ? -1
[tester::#NA2] replica-3: Sent bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[tester::#NA2] replica-3: Received bytes: "+FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0\r\n"
[tester::#NA2] replica-3: Received RESP simple string: "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Received "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Reading RDB file...
[tester::#NA2] 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::#NA2] Received RDB file
[tester::#NA2] Creating replica: 4
[tester::#NA2] replica-4: $ redis-cli PING
[tester::#NA2] replica-4: Sent bytes: "*1\r\n$4\r\nPING\r\n"
[tester::#NA2] replica-4: Received bytes: "+PONG\r\n"
[tester::#NA2] replica-4: Received RESP simple string: "PONG"
[tester::#NA2] Received "PONG"
[tester::#NA2] replica-4: > REPLCONF listening-port 6383
[tester::#NA2] replica-4: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6383\r\n"
[tester::#NA2] replica-4: Received bytes: "+OK\r\n"
[tester::#NA2] replica-4: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-4: > REPLCONF capa psync2
[tester::#NA2] replica-4: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[tester::#NA2] replica-4: Received bytes: "+OK\r\n"
[tester::#NA2] replica-4: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] replica-4: > PSYNC ? -1
[tester::#NA2] replica-4: Sent bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[tester::#NA2] replica-4: Received bytes: "+FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0\r\n"
[tester::#NA2] replica-4: Received RESP simple string: "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Received "FULLRESYNC Qz5PXEBviCMB2sFCD2dN035qWdJlltndIViZ72iz 0"
[tester::#NA2] Reading RDB file...
[tester::#NA2] replica-4: 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::#NA2] Received RDB file
[tester::#NA2] client: $ redis-cli SET foo 123
[tester::#NA2] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[tester::#NA2] client: Received bytes: "+OK\r\n"
[tester::#NA2] client: Received RESP simple string: "OK"
[tester::#NA2] Received "OK"
[tester::#NA2] client: > WAIT 1 500
[tester::#NA2] client: Sent bytes: "*3\r\n$4\r\nWAIT\r\n$1\r\n1\r\n$3\r\n500\r\n"
[tester::#NA2] Testing Replica : 1
[tester::#NA2] replica-1: Expecting "SET foo 123" to be propagated
[tester::#NA2] replica-1: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[tester::#NA2] replica-1: Received RESP array: ["SET", "foo", "123"]
[tester::#NA2] Received ["SET", "foo", "123"]
[tester::#NA2] replica-1: Expecting "REPLCONF GETACK *" from Master
[tester::#NA2] replica-1: Received bytes: "*3\r\n$8\r\nreplconf\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[tester::#NA2] replica-1: Received RESP array: ["replconf", "GETACK", "*"]
[tester::#NA2] Received ["replconf", "GETACK", "*"]
[tester::#NA2] replica-1: Sending ACK to Master
[tester::#NA2] replica-1: $ redis-cli REPLCONF ACK 31
[tester::#NA2] replica-1: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$2\r\n31\r\n"
[tester::#NA2] Testing Replica : 2
[tester::#NA2] replica-2: Expecting "SET foo 123" to be propagated
[tester::#NA2] replica-2: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[tester::#NA2] replica-2: Received RESP array: ["SET", "foo", "123"]
[tester::#NA2] Received ["SET", "foo", "123"]
[tester::#NA2] replica-2: Expecting "REPLCONF GETACK *" from Master
[tester::#NA2] replica-2: Received bytes: "*3\r\n$8\r\nreplconf\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[tester::#NA2] replica-2: Received RESP array: ["replconf", "GETACK", "*"]
[tester::#NA2] Received ["replconf", "GETACK", "*"]
[tester::#NA2] replica-2: Not sending ACK to Master
[tester::#NA2] Testing Replica : 3
[tester::#NA2] replica-3: Expecting "SET foo 123" to be propagated
[tester::#NA2] replica-3: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[tester::#NA2] replica-3: Received RESP array: ["SET", "foo", "123"]
[tester::#NA2] Received ["SET", "foo", "123"]
[tester::#NA2] replica-3: Expecting "REPLCONF GETACK *" from Master
[tester::#NA2] replica-3: Received bytes: "*3\r\n$8\r\nreplconf\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[tester::#NA2] replica-3: Received RESP array: ["replconf", "GETACK", "*"]
[tester::#NA2] Received ["replconf", "GETACK", "*"]
[tester::#NA2] replica-3: Not sending ACK to Master
[tester::#NA2] Testing Replica : 4
[tester::#NA2] replica-4: Expecting "SET foo 123" to be propagated
[tester::#NA2] replica-4: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[tester::#NA2] replica-4: Received RESP array: ["SET", "foo", "123"]
[tester::#NA2] Received ["SET", "foo", "123"]
[tester::#NA2] replica-4: Expecting "REPLCONF GETACK *" from Master
[tester::#NA2] replica-4: Received bytes: "*3\r\n$8\r\nreplconf\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[tester::#NA2] replica-4: Received RESP array: ["replconf", "GETACK", "*"]
[tester::#NA2] Received ["replconf", "GETACK", "*"]
[tester::#NA2] replica-4: Not sending ACK to Master
[tester::#NA2] client: Received bytes: ":1\r\n"
[tester::#NA2] client: Received RESP integer: 1
[tester::#NA2] Passed first WAIT test.
[tester::#NA2] client: > SET baz 789
[tester::#NA2] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
[tester::#NA2] Received: "" (no content received)
[tester::#NA2] ^ error
[tester::#NA2] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
[tester::#NA2] Test failed
[tester::#NA2] Terminating program
[tester::#NA2] Program terminated successfully