This test shows flaky behaviour on my submitted source code. I don’t know whether its the platform or my code that is problematic. Below are the two types of logs during one such failed test:
Type I:
[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"
[your_program] Attaching slave to master: localhost 6379
[your_program] Connected to master server [fd=3, master=localhost:6379]
[your_program] Sent: *1
[your_program] $4
[your_program] PING
[your_program] to [fd=3]
[your_program] Server socket listening on port 6380 [fd=4]
[your_program] Waiting for clients to connect...
[tester::#YD3] [handshake] [master] Waiting for replica to initiate handshake with "PING" command
[tester::#YD3] [handshake] [master] Received ["PING"]
[tester::#YD3] [handshake] [master] Sent "PONG"
[tester::#YD3] [handshake] [master] Waiting for replica to send "REPLCONF listening-port 6380" command
[tester::#YD3] [handshake] [master] Received [
[tester::#YD3] [handshake] [master] "REPLCONF",
[tester::#YD3] [handshake] [master] "listening-port",
[tester::#YD3] [handshake] [master] "6380"
[tester::#YD3] [handshake] [master] ]
[tester::#YD3] [handshake] [master] Sent "OK"
[your_program] Received: +PONG
[your_program] from master: 3
[tester::#YD3] [handshake] [master] Waiting for replica to send "REPLCONF capa" command
[your_program] PING complete
[your_program] Sent: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $14
[your_program] listening-port
[your_program] $4
[your_program] 6380
[your_program] to [fd=3]
[your_program] Received: +OK
[your_program] from master: 3
[your_program] Sent: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $4
[your_program] capa
[your_program] $6
[your_program] psync2
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "PSYNC" command
[your_program] Received: +OK
[your_program] from master: 3
[tester::#YD3] [handshake] [master] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "PSYNC" command
[your_program] Received: +OK
[your_program] from master: 3
[your_program] Repl configured
[your_program] Sent: *3
[your_program] $5
[your_program] PSYNC
[your_program] $1
[your_program] ?
[your_program] $2
[your_program] -1
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["PSYNC", "?", "-1"]
[tester::#YD3] [handshake] [master] Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"
[tester::#YD3] [handshake] [master] Sent RDB file.
[your_program] Received: +FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0
[your_program] from master: 3
[tester::#YD3] [test] [master] > REPLCONF GETACK *
[your_program] FULLRESYNC recieved
[your_program] Received: $88
[your_program] REDIS0011 �redis-ver7.2.0
�[your_program] redis-bits�@�ctime��used-mem°�aof-base���n;���Z�*3
�[your_program] $8
[your_program] REPLCONF
[your_program] $6
[your_program] GETACK
[your_program] $1
[your_program] *
[your_program] from master [fd=3]
[your_program] Received RDB file from master [fd=3]
[your_program] Sent: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $3
[your_program] ACK
[your_program] $1
[your_program] 0
[your_program] to [fd=3]
[tester::#YD3] [test] [master] Received ["REPLCONF", "ACK", "0"]
[tester::#YD3] [propagation] [master] > PING
[tester::#YD3] [test] [master] > REPLCONF GETACK *
[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 (try setting 'debug: true' in your codecrafters.yml to see more details)
Type II:
[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"
[your_program] Attaching slave to master: localhost 6379
[your_program] Connected to master server [fd=3, master=localhost:6379]
[your_program] Sent: *1
[tester::#YD3] [handshake] [master] Waiting for replica to initiate handshake with "PING" command
[your_program] $4
[your_program] PING
[your_program] to [fd=3]
[your_program] Server socket listening on port 6380 [fd=4]
[your_program] Waiting for clients to connect...
[tester::#YD3] [handshake] [master] Received ["PING"]
[tester::#YD3] [handshake] [master] Sent "PONG"
[tester::#YD3] [handshake] [master] Waiting for replica to send "REPLCONF listening-port 6380" command
[your_program] Received: +PONG
[your_program] from master: 3
[your_program] PING complete
[your_program] Sent: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $14
[your_program] listening-port
[your_program] $4
[your_program] 6380
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received [
[tester::#YD3] [handshake] [master] "REPLCONF",
[tester::#YD3] [handshake] [master] "listening-port",
[tester::#YD3] [handshake] [master] "6380"
[tester::#YD3] [handshake] [master] ]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "REPLCONF capa" command
[your_program] Received: +OK
[your_program] from master: 3
[your_program] Sent: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $4
[your_program] capa
[your_program] $6
[your_program] psync2
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "PSYNC" command
[your_program] psync2
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "PSYNC" command
[your_program] psync2
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "PSYNC" command
[your_program] psync2
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "PSYNC" command
[your_program] psync2
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["REPLCONF", "capa", "psync2"]
[tester::#YD3] [handshake] [master] Sent "OK"
[tester::#YD3] [handshake] [master] Waiting for replica to send "PSYNC" command
[your_program] Received: +OK
[your_program] from master: 3
[your_program] Repl configured
[your_program] Sent: *3
[your_program] $5
[your_program] PSYNC
[your_program] $1
[your_program] ?
[your_program] $2
[your_program] -1
[your_program] to [fd=3]
[tester::#YD3] [handshake] [master] Received ["PSYNC", "?", "-1"]
[tester::#YD3] [handshake] [master] Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"
[tester::#YD3] [handshake] [master] Sent RDB file.
[tester::#YD3] [test] [master] > REPLCONF GETACK *
[your_program] Received: +FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0
[your_program] from master: 3
[your_program] FULLRESYNC recieved
[your_program] Received: $88
[your_program] REDIS0011 �redis-ver7.2.0
�[your_program] redis-bits�@�ctime��used-mem°�aof-base���n;���Z�*3
�[your_program] $8
[your_program] REPLCONF
[your_program] $6
[your_program] GETACK
[your_program] $1
[your_program] *
[your_program] from master [fd=3]
[your_program] Received RDB file from master [fd=3]
[your_program] Sent: *3
[your_program] $8
[your_program] REPLCONF
[your_program] $3
[your_program] ACK
[your_program] $1
[your_program] 0
[your_program] to [fd=3]
[tester::#YD3] [test] [master] Received ["REPLCONF", "ACK", "0"]
[tester::#YD3] [propagation] [master] > PING
[tester::#YD3] [test] [master] > REPLCONF GETACK *
[tester::#YD3] write tcp 127.0.0.1:6379->127.0.0.1:43784: write: broken pipe
[tester::#YD3] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)