Hello @andy1li
Appreciate your response.
Can you please explain how the master, through your tests, invoke this command? I would like to re-create the flow locally without running the tests. How the master is triggered to send a REPLCONF GETACK 1
Is there a way to test one test instead of the suite? Because running each test makes it quite difficult to understand what is happening at times.
The tests are also not consistent and it is confusing to understand which is the right way to handle it.
These are two subsequent codecrafters test calls. For YD3, notice these two failures.
[tester::#YD3] Master is running on port 6379
[tester::#YD3] $ ./your_program.sh --port 6380 --replicaof "localhost 6379"
[tester::#YD3] [handshake] master: Waiting for replica to initiate handshake with "PING" command
[tester::#YD3] [handshake] master: Received bytes: "*1\r\n$4\r\nPING\r\n"
[tester::#YD3] [handshake] master: Received RESP array: ["PING"]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received ["PING"]
[tester::#YD3] [handshake]
[your_program] SENDING COMMAND: *1
[your_program] $4
[your_program] PING
[your_program]
[tester::#YD3] [handshake] master: Sent "PONG"
[tester::#YD3] [handshake] master: Sent bytes: "+PONG\r\n"
[tester::#YD3] [handshake] master: Waiting for replica to send "REPLCONF listening-port 6380" command
[tester::#YD3] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"
[tester::#YD3] [handshake] master: Received RESP array: [
[tester::#YD3] [handshake] "REPLCONF",
[tester::#YD3] [handshake] "listening-port",
[tester::#YD3] [handshake] "6380"
[tester::#YD3] [handshake] ]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received [
[tester::#YD3] [handshake] "REPLCONF",
[tester::#YD3] [handshake] "listening-port",
[tester::#YD3] [handshake] "6380"
[tester::#YD3] [handshake] ]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] master: Sent "OK"
[tester::#YD3] [handshake] master: Sent bytes: "+OK\r\n"
[your_program] THIS is the RESPONSE: b'+PONG\r\n'
[your_program] SENDING COMMAND: *3
[tester::#YD3] [handshake] master: Waiting for replica to send "REPLCONF capa" command
[your_program] $8
[your_program] REPLCONF
[your_program] $14
[your_program] listening-port
[your_program] $4
[your_program] 6380
[your_program]
[tester::#YD3] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[tester::#YD3] [handshake] master: Received RESP array: ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake]
[your_program] THIS is the RESPONSE: b'+OK\r\n'
[your_program] SENDING COMMAND: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $4
[your_program] capa
[your_program] $6
[your_program] psync2
[your_program]
[tester::#YD3] [handshake] master: Sent "OK"
[tester::#YD3] [handshake] master: Sent bytes: "+OK\r\n"
[tester::#YD3] [handshake] master: Waiting for replica to send "PSYNC" command
[tester::#YD3] [handshake] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[tester::#YD3] [handshake] master: Received RESP array: ["PSYNC", "?", "-1"]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received ["PSYNC", "?", "-1"]
[tester::#YD3] [handshake]
[your_program] THIS is the RESPONSE: b'+OK\r\n'
[your_program] SENDING COMMAND: *3
[your_program] $5
[your_program] PSYNC
[your_program] $1
[your_program] ?
[your_program] $2
[your_program] -1
[your_program]
[tester::#YD3] [handshake] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"
[tester::#YD3] [handshake] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"
[tester::#YD3] [handshake] Sending RDB file...
[tester::#YD3] [handshake] 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"
[tester::#YD3] [handshake] Sent RDB file.
[tester::#YD3] [test] master: > REPLCONF GETACK *
[tester::#YD3] [test] master: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[your_program] THIS is the RESPONSE: b'+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n$88\r\nREDIS0011\xfa\tredis-ver\x057.2.0\xfa\nredis-bits\xc0@\xfa\x05ctime\xc2m\x08\xbce\xfa\x08used-mem\xc2\xb0\xc4\x10\x00\xfa\x08aof-base\xc0\x00\xff\xf0n;\xfe\xc0\xffZ\xa2*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
[tester::#YD3] Received: "" (no content received)
[tester::#YD3] ^ error
[tester::#YD3] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
[tester::#YD3] Test failed
[tester::#YD3] Terminating program
[tester::#YD3] Program terminated successfully
this is the second call
[tester::#YD3] Running tests for Stage #YD3 (Replication - ACKs with commands)
[tester::#YD3] Master is running on port 6379
[tester::#YD3] $ ./your_program.sh --port 6380 --replicaof "localhost 6379"
[tester::#YD3] [handshake] master: Waiting for replica to initiate handshake with "PING" command
[your_program] SENDING COMMAND: *1
[your_program] $4
[your_program] PING
[your_program]
[tester::#YD3] [handshake] master: Received bytes: "*1\r\n$4\r\nPING\r\n"
[tester::#YD3] [handshake] master: Received RESP array: ["PING"]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received ["PING"]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] master: Sent "PONG"
[tester::#YD3] [handshake] master: Sent bytes: "+PONG\r\n"
[tester::#YD3] [handshake] master: Waiting for replica to send "REPLCONF listening-port 6380" command
[tester::#YD3] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"
[tester::#YD3] [handshake] master: Received RESP array: [
[tester::#YD3] [handshake] "REPLCONF",
[tester::#YD3] [handshake] "listening-port",
[tester::#YD3] [handshake] "6380"
[tester::#YD3] [handshake] ]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received [
[tester::#YD3] [handshake] "REPLCONF",
[tester::#YD3] [handshake] "listening-port",
[tester::#YD3] [handshake] "6380"
[tester::#YD3] [handshake] ]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] master: Sent "OK"
[tester::#YD3] [handshake] master: Sent bytes: "+OK\r\n"
[tester::#YD3] [handshake] master: Waiting for replica to send "REPLCONF capa" command
[your_program] THIS is the RESPONSE: +PONG
[your_program]
[your_program] THIS is the COMMANDS: []
[your_program] THIS is the initial_request
[your_program] SENDING COMMAND: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $14
[your_program] listening-port
[your_program] $4
[your_program] 6380
[your_program]
[your_program] THIS is the RESPONSE: +OK
[your_program]
[tester::#YD3] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[tester::#YD3] [handshake] master: Received RESP array: ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake]
[your_program] THIS is the COMMANDS: []
[your_program] THIS is the initial_request
[your_program] SENDING COMMAND: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $4
[your_program] capa
[your_program] $6
[your_program] psync2
[your_program]
[tester::#YD3] [handshake] master: Sent "OK"
[tester::#YD3] [handshake] master: Sent bytes: "+OK\r\n"
[tester::#YD3] [handshake] master: Waiting for replica to send "PSYNC" command
[tester::#YD3] [handshake] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[your_program] THIS is the RESPONSE: +OK
[your_program]
[tester::#YD3] [handshake] master: Received RESP array: ["PSYNC", "?", "-1"]
[tester::#YD3] [handshake]
[tester::#YD3] [handshake] Received ["PSYNC", "?", "-1"]
[tester::#YD3] [handshake]
[your_program] THIS is the COMMANDS: []
[your_program] THIS is the initial_request
[your_program] SENDING COMMAND: *3
[your_program] $5
[your_program] PSYNC
[your_program] $1
[your_program] ?
[your_program] $2
[your_program] -1
[your_program]
[tester::#YD3] [handshake] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"
[tester::#YD3] [handshake] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"
[tester::#YD3] [handshake] Sending RDB file...
[tester::#YD3] [handshake] 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"
[tester::#YD3] [handshake] Sent RDB file.
[tester::#YD3] [test] master: > REPLCONF GETACK *
[tester::#YD3] [test] master: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[tester::#YD3] [test] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$1\r\n0\r\n"
[tester::#YD3] [test] master: Received RESP array: ["REPLCONF", "ACK", "0"]
[tester::#YD3] [test]
[your_program] THIS is the RESPONSE: +FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0
[your_program]
[your_program] THIS is the COMMANDS: []
[your_program] THIS is the initial_request
[your_program] RDATA IS: b'$88\r\nREDIS0011\xfa\tredis-ver\x057.2.0\xfa\nredis-bits\xc0@\xfa\x05ctime\xc2m\x08\xbce\xfa\x08used-mem\xc2\xb0\xc4\x10\x00\xfa\x08aof-base\xc0\x00\xff\xf0n;\xfe\xc0\xffZ\xa2*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
[your_program] LEN INITIAL REQUEST: 113
[your_program] REPL_CONF_INITIAL_OFFSET PRE: 0
[your_program] INITIAL REQUEST AFTER PRC: $8
[your_program] REPLCONF
[your_program] $6
[your_program] GETACK
[your_program] $1
[your_program] *
[your_program]
[your_program] REPL_CONF_INITIAL_OFFSET POST: 33
[your_program] WHATS THE RESPONSE: b'*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$1\r\n0\r\n'
[tester::#YD3] [test] Received ["REPLCONF", "ACK", "0"]
[tester::#YD3] [test]
[tester::#YD3] [propagation] master: > PING
[tester::#YD3] [propagation] master: Sent bytes: "*1\r\n$4\r\nPING\r\n"
[tester::#YD3] [test] master: > REPLCONF GETACK *
[tester::#YD3] [test] master: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[tester::#YD3] [test] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$2\r\n33\r\n"
[tester::#YD3] [test] master: Received RESP array: ["REPLCONF", "ACK", "33"]
[tester::#YD3] [test]
[tester::#YD3] Expected argument #2 to be "51", got "33"
[tester::#YD3] Test failed
[tester::#YD3] Terminating program
[your_program] RDATA IS: b'*1\r\n$4\r\nPING\r\n*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
[your_program] LEN INITIAL REQUEST: 51
[your_program] REPL_CONF_INITIAL_OFFSET PRE: 33
[your_program] INITIAL REQUEST AFTER PRC: $8
[your_program] REPLCONF
[your_program] $6
[your_program] GETACK
[your_program] $1
[your_program] *
[your_program]
[your_program] REPL_CONF_INITIAL_OFFSET POST: 66
[your_program] WHATS THE RESPONSE: b'*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$2\r\n33\r\n'
[tester::#YD3] Program terminated successfully```
Can you explain why this occurs? Two same calls and two different failures. Can you give me an exact detail of how the Master will be used to send a call to the Slave? Does it come from the redis-cli to the Master to the Slave. Or is there another way? Because it seems there are two distinct ways the message is being relayed to the Slave.
Thank you