Go trouble with replica processing commands

I’m stuck on this redis challenge Stage #Command Processing #yg4 and ACKs with no commands #xv6.

The test runners seem flaky likely due to a bug with how I am reading data from the connection. What is happening is that sometimes I do not receive some of the commands sent by the test master

I’ve tried … (mention what you’ve tried so far).
I have replicated the tests locally with the actual redis-server and established a success connection. Replications and propagation works as well but my test fail intermittently , it fails more than it passes.

Sample logs from the test

tester::#XV6] Running tests for Stage #XV6 (Replication - ACKs with no commands)

[tester::#XV6] Master is running on port 6379

[tester::#XV6] $ ./your_program.sh --port 6380 --replicaof "localhost 6379"

[your_program] Starting server...

[tester::#XV6] [handshake] master: Waiting for replica to initiate handshake with "PING" command

[your_program] Initializing Handshake: [::1]:6379

[your_program] Sending result: "*1\r\n$4\r\nPING\r\n"

[tester::#XV6] [handshake] master: Received bytes: "*1\r\n$4\r\nPING\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["PING"]

[tester::#XV6] [handshake] Received ["PING"]

[tester::#XV6] [handshake] master: Sent "PONG"

[tester::#XV6] [handshake] master: Sent bytes: "+PONG\r\n"

[tester::#XV6] [handshake] master: Waiting for replica to send "REPLCONF listening-port 6380" command

[tester::#XV6] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["REPLCONF", "listening-port", "6380"]

[tester::#XV6] [handshake] Received ["REPLCONF", "listening-port", "6380"]

[tester::#XV6] [handshake] master: Sent "OK"

[tester::#XV6] [handshake] master: Sent bytes: "+OK\r\n"

[your_program] Ping response: PONG

[your_program] Sending result: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[tester::#XV6] [handshake] master: Waiting for replica to send "REPLCONF capa" command

[your_program] REPLCONF response: OK

[tester::#XV6] [handshake] master: Received bytes: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["REPLCONF", "capa", "psync2", "capa", "eof"]

[tester::#XV6] [handshake] Received ["REPLCONF", "capa", "psync2", "capa", "eof"]

[your_program] Sending result: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#XV6] [handshake] master: Sent "OK"

[tester::#XV6] [handshake] master: Sent bytes: "+OK\r\n"

[tester::#XV6] [handshake] master: Waiting for replica to send "PSYNC" command

[tester::#XV6] [handshake] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["PSYNC", "?", "-1"]

[tester::#XV6] [handshake] Received ["PSYNC", "?", "-1"]

[your_program] REPLCONF response: OK

[your_program] Sending result: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#XV6] [handshake] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"

[tester::#XV6] [handshake] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"

[tester::#XV6] [handshake] Sending RDB file...

[tester::#XV6] [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::#XV6] [handshake] Sent RDB file.

[tester::#XV6] [test] master: > REPLCONF GETACK *

[tester::#XV6] [test] master: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"

[your_program] PSYNC response: FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0

[your_program] Reading RDB file

[your_program] RDB file length: 88

[your_program] No databases found in dumpFile file

[your_program] Slave - New connection from: [::1]:6379

[your_program] [SLAVE] Processed - Command: [REPLCONF GETACK *]

[tester::#XV6] [test] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$1\r\n0\r\n"

[tester::#XV6] [test] master: Received RESP array: ["REPLCONF", "ACK", "0"]

[your_program] Sending result: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$1\r\n0\r\n"

[tester::#XV6] [test] Received ["REPLCONF", "ACK", "0"]

[tester::#XV6] Test passed.

[tester::#XV6] Terminating program

[your_program] Client disconnected

[your_program] Shutting down server...

[your_program] Server stopped.

[tester::#XV6] Program terminated successfully

[tester::#YG4] Running tests for Stage #YG4 (Replication - Command Processing)

[tester::#YG4] Master is running on port 6379

[tester::#YG4] $ ./your_program.sh --port 6380 --replicaof "localhost 6379"

[your_program] Starting server...

[tester::#YG4] [handshake] master: Waiting for replica to initiate handshake with "PING" command

[tester::#YG4] [handshake] master: Received bytes: "*1\r\n$4\r\nPING\r\n"

[your_program] Initializing Handshake: [::1]:6379

[your_program] Sending result: "*1\r\n$4\r\nPING\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["PING"]

[tester::#YG4] [handshake] Received ["PING"]

[tester::#YG4] [handshake] master: Sent "PONG"

[tester::#YG4] [handshake] master: Sent bytes: "+PONG\r\n"

[tester::#YG4] [handshake] master: Waiting for replica to send "REPLCONF listening-port 6380" command

[tester::#YG4] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["REPLCONF", "listening-port", "6380"]

[tester::#YG4] [handshake] Received ["REPLCONF", "listening-port", "6380"]

[tester::#YG4] [handshake] master: Sent "OK"

[tester::#YG4] [handshake] master: Sent bytes: "+OK\r\n"

[tester::#YG4] [handshake] master: Waiting for replica to send "REPLCONF capa" command

[your_program] Ping response: PONG

[your_program] Sending result: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[your_program] REPLCONF response: OK

[tester::#YG4] [handshake] master: Received bytes: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["REPLCONF", "capa", "psync2", "capa", "eof"]

[tester::#YG4] [handshake] Received ["REPLCONF", "capa", "psync2", "capa", "eof"]

[your_program] Sending result: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#YG4] [handshake] master: Sent "OK"

[tester::#YG4] [handshake] master: Sent bytes: "+OK\r\n"

[tester::#YG4] [handshake] master: Waiting for replica to send "PSYNC" command

[tester::#YG4] [handshake] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["PSYNC", "?", "-1"]

[tester::#YG4] [handshake] Received ["PSYNC", "?", "-1"]

[your_program] REPLCONF response: OK

[your_program] Sending result: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#YG4] [handshake] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"

[tester::#YG4] [handshake] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"

[tester::#YG4] [handshake] Sending RDB file...

[tester::#YG4] [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::#YG4] [handshake] Sent RDB file.

[your_program] PSYNC response: FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0

[your_program] Reading RDB file

[tester::#YG4] [propagation] master: > SET foo 123

[tester::#YG4] [propagation] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"

[tester::#YG4] [propagation] master: > SET bar 456

[tester::#YG4] [propagation] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n"

[tester::#YG4] [propagation] master: > SET baz 789

[tester::#YG4] [propagation] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"

[tester::#YG4] [test] Getting key foo

[tester::#YG4] [test] client: $ redis-cli GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[your_program] Error reading RDB file: expected $ prefix, got *

[your_program] Slave - New connection from: [::1]:47630

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] Retrying... (1/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] Retrying... (2/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[tester::#YG4] [test] Retrying... (3/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[tester::#YG4] [test] Retrying... (4/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] Retrying... (5/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[tester::#YG4] Expected simple string or bulk string, got NIL

[tester::#YG4] Test failed

[tester::#YG4] Terminating program

[your_program] Client disconnected

[your_program] Shutting down server...

[your_program] Server stopped.

[tester::#YG4] Program terminated successfully
Here are my logs: 
[tester::#XV6] Running tests for Stage #XV6 (Replication - ACKs with no commands)

[tester::#XV6] Master is running on port 6379

[tester::#XV6] $ ./your_program.sh --port 6380 --replicaof "localhost 6379"

[your_program] Starting server...

[tester::#XV6] [handshake] master: Waiting for replica to initiate handshake with "PING" command

[your_program] Initializing Handshake: [::1]:6379

[your_program] Sending result: "*1\r\n$4\r\nPING\r\n"

[tester::#XV6] [handshake] master: Received bytes: "*1\r\n$4\r\nPING\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["PING"]

[tester::#XV6] [handshake] Received ["PING"]

[tester::#XV6] [handshake] master: Sent "PONG"

[tester::#XV6] [handshake] master: Sent bytes: "+PONG\r\n"

[tester::#XV6] [handshake] master: Waiting for replica to send "REPLCONF listening-port 6380" command

[tester::#XV6] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["REPLCONF", "listening-port", "6380"]

[tester::#XV6] [handshake] Received ["REPLCONF", "listening-port", "6380"]

[tester::#XV6] [handshake] master: Sent "OK"

[tester::#XV6] [handshake] master: Sent bytes: "+OK\r\n"

[your_program] Ping response: PONG

[your_program] Sending result: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[tester::#XV6] [handshake] master: Waiting for replica to send "REPLCONF capa" command

[your_program] REPLCONF response: OK

[tester::#XV6] [handshake] master: Received bytes: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["REPLCONF", "capa", "psync2", "capa", "eof"]

[tester::#XV6] [handshake] Received ["REPLCONF", "capa", "psync2", "capa", "eof"]

[your_program] Sending result: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#XV6] [handshake] master: Sent "OK"

[tester::#XV6] [handshake] master: Sent bytes: "+OK\r\n"

[tester::#XV6] [handshake] master: Waiting for replica to send "PSYNC" command

[tester::#XV6] [handshake] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#XV6] [handshake] master: Received RESP array: ["PSYNC", "?", "-1"]

[tester::#XV6] [handshake] Received ["PSYNC", "?", "-1"]

[your_program] REPLCONF response: OK

[your_program] Sending result: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#XV6] [handshake] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"

[tester::#XV6] [handshake] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"

[tester::#XV6] [handshake] Sending RDB file...

[tester::#XV6] [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::#XV6] [handshake] Sent RDB file.

[tester::#XV6] [test] master: > REPLCONF GETACK *

[tester::#XV6] [test] master: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"

[your_program] PSYNC response: FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0

[your_program] Reading RDB file

[your_program] RDB file length: 88

[your_program] No databases found in dumpFile file

[your_program] Slave - New connection from: [::1]:6379

[your_program] [SLAVE] Processed - Command: [REPLCONF GETACK *]

[tester::#XV6] [test] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$1\r\n0\r\n"

[tester::#XV6] [test] master: Received RESP array: ["REPLCONF", "ACK", "0"]

[your_program] Sending result: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$1\r\n0\r\n"

[tester::#XV6] [test] Received ["REPLCONF", "ACK", "0"]

[tester::#XV6] Test passed.

[tester::#XV6] Terminating program

[your_program] Client disconnected

[your_program] Shutting down server...

[your_program] Server stopped.

[tester::#XV6] Program terminated successfully

[tester::#YG4] Running tests for Stage #YG4 (Replication - Command Processing)

[tester::#YG4] Master is running on port 6379

[tester::#YG4] $ ./your_program.sh --port 6380 --replicaof "localhost 6379"

[your_program] Starting server...

[tester::#YG4] [handshake] master: Waiting for replica to initiate handshake with "PING" command

[tester::#YG4] [handshake] master: Received bytes: "*1\r\n$4\r\nPING\r\n"

[your_program] Initializing Handshake: [::1]:6379

[your_program] Sending result: "*1\r\n$4\r\nPING\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["PING"]

[tester::#YG4] [handshake] Received ["PING"]

[tester::#YG4] [handshake] master: Sent "PONG"

[tester::#YG4] [handshake] master: Sent bytes: "+PONG\r\n"

[tester::#YG4] [handshake] master: Waiting for replica to send "REPLCONF listening-port 6380" command

[tester::#YG4] [handshake] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["REPLCONF", "listening-port", "6380"]

[tester::#YG4] [handshake] Received ["REPLCONF", "listening-port", "6380"]

[tester::#YG4] [handshake] master: Sent "OK"

[tester::#YG4] [handshake] master: Sent bytes: "+OK\r\n"

[tester::#YG4] [handshake] master: Waiting for replica to send "REPLCONF capa" command

[your_program] Ping response: PONG

[your_program] Sending result: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"

[your_program] REPLCONF response: OK

[tester::#YG4] [handshake] master: Received bytes: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["REPLCONF", "capa", "psync2", "capa", "eof"]

[tester::#YG4] [handshake] Received ["REPLCONF", "capa", "psync2", "capa", "eof"]

[your_program] Sending result: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n$4\r\ncapa\r\n$3\r\neof\r\n"

[tester::#YG4] [handshake] master: Sent "OK"

[tester::#YG4] [handshake] master: Sent bytes: "+OK\r\n"

[tester::#YG4] [handshake] master: Waiting for replica to send "PSYNC" command

[tester::#YG4] [handshake] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#YG4] [handshake] master: Received RESP array: ["PSYNC", "?", "-1"]

[tester::#YG4] [handshake] Received ["PSYNC", "?", "-1"]

[your_program] REPLCONF response: OK

[your_program] Sending result: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"

[tester::#YG4] [handshake] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"

[tester::#YG4] [handshake] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"

[tester::#YG4] [handshake] Sending RDB file...

[tester::#YG4] [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::#YG4] [handshake] Sent RDB file.

[your_program] PSYNC response: FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0

[your_program] Reading RDB file

[tester::#YG4] [propagation] master: > SET foo 123

[tester::#YG4] [propagation] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"

[tester::#YG4] [propagation] master: > SET bar 456

[tester::#YG4] [propagation] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n"

[tester::#YG4] [propagation] master: > SET baz 789

[tester::#YG4] [propagation] master: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"

[tester::#YG4] [test] Getting key foo

[tester::#YG4] [test] client: $ redis-cli GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[your_program] Error reading RDB file: expected $ prefix, got *

[your_program] Slave - New connection from: [::1]:47630

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] Retrying... (1/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] Retrying... (2/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[tester::#YG4] [test] Retrying... (3/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[tester::#YG4] [test] Retrying... (4/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] Retrying... (5/5 attempts)

[tester::#YG4] [test] client: > GET foo

[tester::#YG4] [test] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n"

[your_program] [SLAVE] Processed - Command: [GET foo]

[your_program] Sending result: "$-1\r\n"

[tester::#YG4] [test] client: Received bytes: "$-1\r\n"

[tester::#YG4] [test] client: Received RESP null bulk string: "$-1\r\n"

[tester::#YG4] Expected simple string or bulk string, got NIL

[tester::#YG4] Test failed

[tester::#YG4] Terminating program

[your_program] Client disconnected

[your_program] Shutting down server...

[your_program] Server stopped.

[tester::#YG4] Program terminated successfully**strong text**
include relevant logs here (please make sure to keep the backticks around this!)

The areas of interest will be

Issue is addressed. The problem was that I used a buffer read writer and the underlying tcp connection interchangeably.

Used the buffered read writer for both writes and reads in the lifecycle of the connection.

1 Like