# Stuck on replication #ZN8

**URL:** https://forum.codecrafters.io/t/stuck-on-replication-zn8/241
**Category:** Challenges
**Tags:** challenge:redis
**Created:** [April 30, 2024, 11:12pm UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241 "2024-04-30T23:12:30Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Jothikumar-ekanath](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/jothikumar-ekanath/32/214_2.png) [@Jothikumar-ekanath](https://forum.codecrafters.io/u/Jothikumar-ekanath)
#### Post date: [April 30, 2024, 11:12pm UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/1 "2024-04-30T23:12:30Z")

</div>

Hi All,  
Need help in debugging this stage (replication -11). I am able to individually run a master, replica and connect with redis-cli clients to the master to watch the logs on the replication. The tester program expecting some output which I am not able to figure out, the logs are so general.

Any help appreciated  
code : [toy-redis-python/app/main.py at master · Jothikumar-ekanath/toy-redis-python · GitHub](https://github.com/Jothikumar-ekanath/toy-redis-python/blob/master/app/main.py)  
Below are the console Logs  
Debug = true

```auto
[replication-11] Running tests for Replication > Stage #11: Single-replica propagation
[replication-11] $ ./spawn_redis_server.sh --port 6379
[your_program] master - Starting the server coroutine on port 6379
[your_program] master - Server running on (‘127.0.0.1’, 6379)
[replication-11] replica: $ redis-cli PING
[replication-11] replica: Sent bytes: “*1\r\n$4\r\nPING\r\n”
[replication-11] replica: Received bytes: “+PONG\r\n”
[replication-11] replica: Received RESP value: “PONG”
[your_program] master - Waiting for the next command from the client…(‘::1’, 55828, 0, 0)
[your_program] master - Waiting for the next command from the client…(‘::1’, 55832, 0, 0)
[your_program] master - RESP parsed_req: [‘PING’] for client (‘::1’, 55832, 0, 0)
[your_program] master - Waiting for the next command from the client…(‘::1’, 55832, 0, 0)
[replication-11] Received “PONG”
[replication-11] replica: $ redis-cli REPLCONF listening-port 6380
[replication-11] replica: Sent bytes: “*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n”
[replication-11] replica: Received bytes: “+OK\r\n”
[replication-11] replica: Received RESP value: “OK”
[your_program] master - RESP parsed_req: [‘REPLCONF’, ‘listening-port’, ‘6380’] for client (‘::1’, 55832, 0, 0)
[your_program] master - Replica connections added for (‘::1’, 55832, 0, 0)
[your_program] master - Waiting for the next command from the client…(‘::1’, 55832, 0, 0)
[replication-11] Received “OK”
[replication-11] replica: $ redis-cli REPLCONF capa psync2
[replication-11] replica: Sent bytes: “*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n”
[replication-11] replica: Received bytes: “+OK\r\n”
[replication-11] replica: Received RESP value: “OK”
[your_program] master - RESP parsed_req: [‘REPLCONF’, ‘capa’, ‘psync2’] for client (‘::1’, 55832, 0, 0)
[your_program] master - Waiting for the next command from the client…(‘::1’, 55832, 0, 0)
[replication-11] Received “OK”
[replication-11] replica: $ redis-cli PSYNC ? -1
[replication-11] replica: Sent bytes: “*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n”
[replication-11] replica: Received bytes: “+FULLRESYNC 8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb 0\r\n”
[replication-11] replica: Received RESP value: “FULLRESYNC 8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb 0”
[replication-11] Received “FULLRESYNC 8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb 0”
[replication-11] Reading RDB file…
[your_program] master - RESP parsed_req: [‘PSYNC’, ‘?’, ‘-1’] for client (‘::1’, 55832, 0, 0)
[your_program] master - Waiting for the next command from the client…(‘::1’, 55832, 0, 0)
[replication-11] replica: Received 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”
[replication-11] Received RDB file
[replication-11] client: $ redis-cli SET foo 123
[replication-11] client: Sent bytes: “*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n”
[replication-11] client: Received bytes: “+OK\r\n”
[replication-11] client: Received RESP value: “OK”
[your_program] master - RESP parsed_req: [‘SET’, ‘foo’, ‘123’] for client (‘::1’, 55828, 0, 0)
[your_program] sent b’*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n’ to replica (‘::1’, 55832, 0, 0)
[your_program] master - Waiting for the next command from the client…(‘::1’, 55828, 0, 0)
[replication-11] Received “OK”
[replication-11] client: $ redis-cli SET bar 456
[replication-11] client: Sent bytes: “*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n”
[your_program] master - RESP parsed_req: [‘SET’, ‘bar’, ‘456’] for client (‘::1’, 55828, 0, 0)
[your_program] sent b’*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n’ to replica (‘::1’, 55832, 0, 0)
[your_program] master - Waiting for the next command from the client…(‘::1’, 55828, 0, 0)
**[replication-11] Received: “” (no content received)**
**[replication-11] ^ error**
**[replication-11] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)**
**[replication-11] Test failed**
[replication-11] Terminating program
[replication-11] Program terminated successfully

```

---

<div class="post-metadata">

### Author: ![Jothikumar-ekanath](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/jothikumar-ekanath/32/214_2.png) [@Jothikumar-ekanath](https://forum.codecrafters.io/u/Jothikumar-ekanath)
#### Post date: [May 1, 2024, 3:23pm UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/2 "2024-05-01T15:23:35Z")

</div>

This is no longer a blocker, was able to fix it. I had used same variable name for writing into client sockets ( both clients connecting to server, also writing to replica’s)  
I still need to refactor the code in a better way so that these issues can be debug

The error message from the tester should have been a little bit elaborative on what it is doing and why we see the message

---

<div class="post-metadata">

### Author: ![inner](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/inner/32/4695_2.png) [@inner](https://forum.codecrafters.io/u/inner)
#### Post date: [May 3, 2024, 6:16am UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/3 "2024-05-03T06:16:21Z")

</div>

> [@Jothikumar-ekanath](#):
>
> e to fix it. I had used same variable name for writing into client sockets ( both clients connecting to server, also writing to replica’s)  
> I still need to refactor the code in a better way so that these issues can be debug
> 
> The error message from the tester shou

Hi, I have the same issue here, would you mind explaining a little bit more about this issue and how did you solve it? Much much appreciated! Thanks

---

<div class="post-metadata">

### Author: ![Jothikumar-ekanath](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/jothikumar-ekanath/32/214_2.png) [@Jothikumar-ekanath](https://forum.codecrafters.io/u/Jothikumar-ekanath)
#### Post date: [May 4, 2024, 12:59am UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/4 "2024-05-04T00:59:45Z")

</div>

The error message given by the tester is so generic, it will hard to debug. Please post the complete error log and code. I can try to debug.

I had a bug in my code where I used the same variable name for both master writing to clients and master replicating the set commands to replicas. once I fixed, the issue resolved

---

<div class="post-metadata">

### Author: ![inner](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/inner/32/4695_2.png) [@inner](https://forum.codecrafters.io/u/inner)
#### Post date: [May 4, 2024, 5:06am UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/5 "2024-05-04T05:06:53Z")

</div>

Thanks for responding. It looks like I have passed this stage after making multiple changes in my code. As you say, the error given is so generic and makes it really hard to debug.

Also, you mentioned the complete error log, do you mean that you can see some sort of detailed error log somewhere in the codecrafters log? I might be missing some information on how to use the codecrafters!

---

<div class="post-metadata">

### Author: ![Jothikumar-ekanath](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/jothikumar-ekanath/32/214_2.png) [@Jothikumar-ekanath](https://forum.codecrafters.io/u/Jothikumar-ekanath)
#### Post date: [May 4, 2024, 6:49pm UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/6 "2024-05-04T18:49:58Z")

</div>

yes, It is hard to debug just using tester’s console output.

Please add more print statements in your code. Along with your print statements and the testers console log output it will eventually become easier to debug

Complete error log, I meant the console output when you run the tests.

---

<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 6, 2024, 1:59pm UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/7 "2024-05-06T13:59:10Z")

</div>

We’re adding logs here to make it more clear what the tester expects. Will keep this open until that’s done!

---

<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, 3:29am UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/8 "2024-06-04T03:29:31Z")

</div>

Note: I’ve updated the title of this post to include the stage ID (#ZN8). You can learn about the stages rename here: [Upcoming change: Stages overhaul](https://forum.codecrafters.io/t/upcoming-change-stages-overhaul/375).

---

<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: [June 18, 2024, 12:13pm UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/9 "2024-06-18T12:13:29Z")

</div>

Logs should now include more details like “Expecting commands to be propagated”.

We’re also going to work on splitting logs into multiple stages (handshake, propagation etc.). Will close for now and wait for similar reports before we make further changes here!

---

<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 23, 2024, 12:13pm UTC](https://forum.codecrafters.io/t/stuck-on-replication-zn8/241/10 "2024-06-23T12:13:54Z")

</div>

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