I’m stuck on Single-replica propagation.
I am learning go-lang and I’m new to debugging errors in golang. But the program seems to run fine when testing manually. I’ve testing using one master node, three replica nodes and one client. PING requests from clients to replicas works fine locally. I’m not sure what the test is exactly trying to do to debug the issue?
https://github.com/thezetrax/redi-go
THIS HAS BEEN FIXED
Update: I had a bug on my application, on replica nodes I was only listening to requests from the master node. That was causing the connection refused when the client tried to connect to the replica node.
Here are my logs:
[replication-3] Running tests for Replication > Stage #3: The INFO command on a replica
[replication-3] Master is running on port 6379
[replication-3] $ ./spawn_redis_server.sh --port 6380 --replicaof localhost 6379
[replication-3] master: Received bytes: "*1\r\n$4\r\nPING\r\n"
[replication-3] master: Received RESP value: ["PING"]
[replication-3] master: Sent "PONG"
[replication-3] master: Sent bytes: "+PONG\r\n"
[replication-3] master: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"
[replication-3] master: Received RESP value: ["REPLCONF", "listening-port", "6380"]
[replication-3] master: Sent "OK"
[replication-3] master: Sent bytes: "+OK\r\n"
[your_program] 2024/04/06 21:47:51 Master[localhost:6379] raw response: +PONG\r\n
[replication-3] master: Received bytes: "*5\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$3\r\neof\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[replication-3] master: Received RESP value: ["REPLCONF", "capa", "eof", "capa", "psync2"]
[your_program] 2024/04/06 21:47:51 Master[localhost:6379] raw response: +OK\r\n
[replication-3] master: Sent "OK"
[replication-3] master: Sent bytes: "+OK\r\n"
[replication-3] master: Received bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[replication-3] master: Received RESP value: ["PSYNC", "?", "-1"]
[your_program] 2024/04/06 21:47:51 Master[localhost:6379] raw response: +OK\r\n
[replication-3] master: Sent "FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0"
[replication-3] master: Sent bytes: "+FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n"
[replication-3] 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"
[your_program] 2024/04/06 21:47:51 Master[localhost:6379] raw response: +FULLRESYNC 75cd7bc10c49047e0d163660f3b90625b1af31dc 0\r\n$88\r\nREDIS0011 redis-ver7.2.0
[your_program] redis-bits@ctimeused-memaof-basen;Z
[your_program] 2024/04/06 21:47:51 Connected to master: localhost:6379
[replication-3] dial tcp [::1]:6380: connect: connection refused
[replication-3] Test failed
[replication-3] Terminating program
[replication-3] Program terminated successfully
Here are the logs:
[your_program] 2024/04/07 02:43:52 PSYNC [? -1]
[replication-9] Received "FULLRESYNC a54dbf36b1f31ce6a681d95ccd78eb313e598c1a 0"
[replication-9] Test passed.
[your_program] Error accepting connection: accept tcp [::]:6379: use of closed network connection
[replication-10] Running tests for Replication > Stage #10: Empty RDB Transfer
[replication-10] $ ./spawn_redis_server.sh --port 6379
[your_program] Redis-server listening on: 6379
[replication-10] client: $ redis-cli PING
[your_program] 2024/04/07 02:43:52 [RAW REQUEST]: *1\r\n$4\r\nPING\r\n
[your_program] 2024/04/07 02:43:52 [RAW REQUEST]: *1\r\n$4\r\nPING\r\n
[your_program] 2024/04/07 02:43:52 PING []
[replication-10] Received "PONG"
[replication-10] client: $ redis-cli REPLCONF listening-port 6380
[your_program] 2024/04/07 02:43:52 [RAW REQUEST]: *3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n
[your_program] 2024/04/07 02:43:52 REPLCONF [listening-port 6380]
[replication-10] Received "OK"
[replication-10] client: $ redis-cli REPLCONF capa psync2
[your_program] 2024/04/07 02:43:52 [RAW REQUEST]: *3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n
[your_program] 2024/04/07 02:43:52 REPLCONF [capa psync2]
[replication-10] Received "OK"
[replication-10] client: $ redis-cli PSYNC ? -1
[your_program] 2024/04/07 02:43:52 [RAW REQUEST]: *3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n
[your_program] 2024/04/07 02:43:52 PSYNC [? -1]
[replication-10] Received "FULLRESYNC 99e16f971c7a6a57f62985f18023cc3fb199fc71 0"
[replication-10] Received RDB file
[replication-10] Test passed.
[your_program] Error accepting connection: accept tcp [::]:6379: use of closed network connection
[replication-11] Running tests for Replication > Stage #11: Single-replica propagation
[replication-11] $ ./spawn_redis_server.sh --port 6379
[your_program] Redis-server listening on: 6379
[replication-11] replica: $ redis-cli PING
[replication-11] Received: ""
[replication-11] ^ error
[replication-11] Error: Expected start of a new RESP value (either +, -, :, $ or *)
[replication-11] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
[your_program] Error reading from connection: EOF
View stage instructions: https://app.codecrafters.io/courses/redis.