Stuck in replication #NA2

I’m stuck on the replication 18th stage. Wondering what is missing in my code. first wait test passed, second one gave some unprecedented error. Same scenario was working for first test. I am writing in JS.

Here are my logs:

remote: [replication-18] replica-2: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
remote: [replication-18] replica-2: Received RESP value: ["REPLCONF", "GETACK", "*"]
remote: [replication-18] Received ["REPLCONF", "GETACK", "*"]
remote: [replication-18] replica-2: Not sending ACK to Master
remote: [replication-18] Testing Replica : 3
remote: [replication-18] replica-3: Expecting "SET foo 123" to be propagated
remote: [replication-18] replica-3: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
remote: [replication-18] replica-3: Received RESP value: ["SET", "foo", "123"]
remote: [replication-18] Received ["SET", "foo", "123"]
remote: [replication-18] replica-3: Expecting "REPLCONF GETACK *" from Master
remote: [replication-18] replica-3: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
remote: [replication-18] replica-3: Received RESP value: ["REPLCONF", "GETACK", "*"]
remote: [replication-18] Received ["REPLCONF", "GETACK", "*"]
remote: [replication-18] replica-3: Not sending ACK to Master
remote: [replication-18] Testing Replica : 4
remote: [replication-18] replica-4: Expecting "SET foo 123" to be propagated
remote: [replication-18] replica-4: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
remote: [replication-18] replica-4: Received RESP value: ["SET", "foo", "123"]
remote: [replication-18] Received ["SET", "foo", "123"]
remote: [replication-18] replica-4: Expecting "REPLCONF GETACK *" from Master
remote: [replication-18] replica-4: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
remote: [replication-18] replica-4: Received RESP value: ["REPLCONF", "GETACK", "*"]
remote: [replication-18] Received ["REPLCONF", "GETACK", "*"]
remote: [replication-18] replica-4: Not sending ACK to Master
remote: [replication-18] client: Received bytes: ":1\r\n"
remote: [replication-18] client: Received RESP value: 1
remote: [replication-18] Passed first WAIT test.
remote: [replication-18] client: $ redis-cli SET baz 789
remote: [replication-18] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
remote: [your_program] Client connected to master server
remote: [your_program] command:set args:baz,789
remote: [your_program] Setting key value pair in cache
remote: [replication-18] client: Received bytes: "+OK\r\n"
remote: [replication-18] client: Received RESP value: "OK"
remote: [your_program] data sent to replicas
remote: [replication-18] Received "OK"
remote: [replication-18] client: $ redis-cli WAIT 3 2000
remote: [replication-18] client: Sent bytes: "*3\r\n$4\r\nWAIT\r\n$1\r\n3\r\n$4\r\n2000\r\n"
remote: [replication-18] Testing Replica : 1
remote: [replication-18] replica-1: Expecting "SET baz 789" to be propagated
remote: [replication-18] replica-1: Received bytes: "+OK\r\n"
remote: [replication-18] replica-1: Received RESP value: "OK"
remote: [your_program] Client connected to master server
remote: [your_program] command:wait args:3,2000
remote: [your_program] wait command
remote: [replication-18] Expected array type, got SIMPLE_STRING
remote: [replication-18] Test failed

Propagation to the replica of SET command is working for the first test but not for the second test. Please help me. I have been stuck here for long.

same for me.
I dont know why it’s happening.
any solution?

Unless you post code here it’s going to be really hard to help :slightly_smiling_face:

You can publish your code to github like this: Publish to GitHub - CodeCrafters

this is my code

this part is handling the propgation

Everything works fine for 1st test but the problem occurs on 2nd WAIT test.

Hi,

I have been able to find one issue in my code. I was registering two On condition, which was causing thee issue. I have surpassed that step. But now I am getting new issue. client is not receiving REPLCONF GETACK * even if I send it. my git repo URL
GitHub - Shubho2/SimpleRedis: Implementation of Basic Redis Protocol.

can you elaborate on what was causing the issue.

Now the logs are

remote: [replication-18] Received ["SET", "foo", "123"]
remote: [replication-18] replica-3: Expecting "REPLCONF GETACK *" from Master
remote: [replication-18] replica-3: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
remote: [replication-18] replica-3: Received RESP value: ["REPLCONF", "GETACK", "*"]
remote: [replication-18] Received ["REPLCONF", "GETACK", "*"]
remote: [replication-18] replica-3: Not sending ACK to Master
remote: [replication-18] client: Received bytes: ":1\r\n"
remote: [replication-18] client: Received RESP value: 1
remote: [replication-18] Passed first WAIT test.
remote: [replication-18] client: $ redis-cli SET baz 789
remote: [replication-18] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
remote: [your_program] Data came to master server
remote: [your_program] command:set args:baz,789
remote: [your_program] Setting key value pair in cache
remote: [replication-18] client: Received bytes: "+OK\r\n"
remote: [replication-18] client: Received RESP value: "OK"
remote: [your_program] data sent to replicas
remote: [replication-18] Received "OK"
remote: [replication-18] client: $ redis-cli WAIT 3 2000
remote: [replication-18] client: Sent bytes: "*3\r\n$4\r\nWAIT\r\n$1\r\n3\r\n$4\r\n2000\r\n"
remote: [replication-18] Testing Replica : 1
remote: [replication-18] replica-1: Expecting "SET baz 789" to be propagated
remote: [replication-18] replica-1: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
remote: [replication-18] replica-1: Received RESP value: ["SET", "baz", "789"]
remote: [replication-18] Received ["SET", "baz", "789"]
remote: [replication-18] replica-1: Expecting "REPLCONF GETACK *" from Master
remote: [your_program] Data came to master server
remote: [your_program] command:wait args:3,2000
remote: [your_program] wait command
remote: [replication-18] Received: "" (no content received)
remote: [replication-18]            ^ error
remote: [replication-18] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
remote: [replication-18] Test failed
remote: [replication-18] Terminating program
remote: [replication-18] Program terminated successfully

Were you getting the same error as me? If yes.
I have accidentally registered two function call when I am getting the reply from replica as REPLCONF ACK <bytes_received>. It is resolved now.

I am asking what was causing the issue at Stage #18
And how did you got past through it.?

Nevermind I got through this problem.
The problem was that I was not recieving the response from Replica ACK.

Hi,

I resolved all issues and passed the stage. We can close this ticket.

1 Like

Glad to hear, nice work!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.

Note: I’ve updated the title of this post to include the stage ID (#NA2). You can learn about the stages rename here: Upcoming change: Stages overhaul.