# Stuck in replication #NA2

**URL:** <https://forum.codecrafters.io/t/stuck-in-replication-na2/385>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [May 14, 2024, 3:59pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385 "2024-05-14T15:59:16Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubho2](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shubho2/32/342_2.png) [@Shubho2](https://forum.codecrafters.io/u/Shubho2)\
**Post date:** [May 14, 2024, 3:59pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/1 "2024-05-14T15:59:16Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![kaifkh20](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/kaifkh20/32/339_2.png) [@kaifkh20](https://forum.codecrafters.io/u/kaifkh20)\
**Post date:** [May 16, 2024, 11:58am UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/2 "2024-05-16T11:58:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [May 16, 2024, 12:56pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/3 "2024-05-16T12:56:20Z")

</div>

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

You can publish your code to github like this: [Publish to GitHub - CodeCrafters](https://docs.codecrafters.io/features/publish-to-github)

---

<div class="post-metadata">

**Author:** ![kaifkh20](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/kaifkh20/32/339_2.png) [@kaifkh20](https://forum.codecrafters.io/u/kaifkh20)\
**Post date:** [May 16, 2024, 1:23pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/4 "2024-05-16T13:23:03Z")

</div>

> **[GitHub - kaifkh20/python-redis](https://github.com/kaifkh20/python-redis)**
>
> Contribute to kaifkh20/python-redis development by creating an account on GitHub.

this is my code

 ![Screenshot at 2024-05-16 18-52-24](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/1X/067c914bff85e9b39e10568989b269bdc7ec4ee0.png)

this part is handling the propgation

---

<div class="post-metadata">

**Author:** ![kaifkh20](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/kaifkh20/32/339_2.png) [@kaifkh20](https://forum.codecrafters.io/u/kaifkh20)\
**Post date:** [May 16, 2024, 1:54pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/6 "2024-05-16T13:54:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shubho2](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shubho2/32/342_2.png) [@Shubho2](https://forum.codecrafters.io/u/Shubho2)\
**Post date:** [May 16, 2024, 3:32pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/7 "2024-05-16T15:32:21Z")

</div>

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](https://github.com/Shubho2/SimpleRedis).

---

<div class="post-metadata">

**Author:** ![kaifkh20](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/kaifkh20/32/339_2.png) [@kaifkh20](https://forum.codecrafters.io/u/kaifkh20)\
**Post date:** [May 16, 2024, 4:38pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/8 "2024-05-16T16:38:03Z")

</div>

can you elaborate on what was causing the issue.

---

<div class="post-metadata">

**Author:** ![Shubho2](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shubho2/32/342_2.png) [@Shubho2](https://forum.codecrafters.io/u/Shubho2)\
**Post date:** [May 16, 2024, 4:42pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/9 "2024-05-16T16:42:56Z")

</div>

Now the logs are

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Shubho2](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shubho2/32/342_2.png) [@Shubho2](https://forum.codecrafters.io/u/Shubho2)\
**Post date:** [May 16, 2024, 4:44pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/10 "2024-05-16T16:44:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kaifkh20](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/kaifkh20/32/339_2.png) [@kaifkh20](https://forum.codecrafters.io/u/kaifkh20)\
**Post date:** [May 16, 2024, 5:13pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/11 "2024-05-16T17:13:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kaifkh20](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/kaifkh20/32/339_2.png) [@kaifkh20](https://forum.codecrafters.io/u/kaifkh20)\
**Post date:** [May 16, 2024, 5:36pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/12 "2024-05-16T17:36:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shubho2](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shubho2/32/342_2.png) [@Shubho2](https://forum.codecrafters.io/u/Shubho2)\
**Post date:** [May 16, 2024, 8:22pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/13 "2024-05-16T20:22:21Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [May 16, 2024, 9:10pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/14 "2024-05-16T21:10:52Z")

</div>

Glad to hear, nice work!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [May 21, 2024, 9:11pm UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/15 "2024-05-21T21:11:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [June 4, 2024, 2:01am UTC](https://forum.codecrafters.io/t/stuck-in-replication-na2/385/16 "2024-06-04T02:01:02Z")

</div>

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](https://forum.codecrafters.io/t/upcoming-change-stages-overhaul/375).
