# Redis Challenge Stage #HD5

**URL:** <https://forum.codecrafters.io/t/redis-challenge-stage-hd5/62>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [April 8, 2024, 4:00pm UTC](https://forum.codecrafters.io/t/redis-challenge-stage-hd5/62 "2024-04-08T16:00:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![harish876](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/harish876/32/52_2.png) [@harish876](https://forum.codecrafters.io/u/harish876)\
**Post date:** [April 8, 2024, 4:00pm UTC](https://forum.codecrafters.io/t/redis-challenge-stage-hd5/62/1 "2024-04-08T16:00:15Z")

</div>

Hey I’m stuck on Redis Challenge Stage 12.

I’ve tried debugging my code by placing logs at places I feel are causing the error behaviour, but i am unable to understand why it is happening.

I am getting an EOF and an empty string , before the get command is fired the replicas to get the replicated messages.

Even though I passed this stage, I still get periodic errors, something which I think has got to do with concurreny and specifically at sending out the messages to the replica. Stage 11 works as expected from my code, but stage 12 is where I lose a lot of clarity.

Here are my logs:

 ![Screenshot 2024-04-08 at 9.22.58 PM](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/1X/d6bbe1a5dd2acf2bebf8e17d052dcb584eb94b18.jpeg)

Here is the link to my github repository. [GitHub - harish876/harish876-codecrafters-redis-go: Code Crafters Build your Own Redis Challenge](https://github.com/harish876/harish876-codecrafters-redis-go)

I think this is the part of my code which isnt working as expected: [harish876-codecrafters-redis-go/pkg/server/replication.go at master · harish876/harish876-codecrafters-redis-go · GitHub](https://github.com/harish876/harish876-codecrafters-redis-go/blob/master/pkg/server/replication.go). Specifically the function that handles the handshake with the master

Any help is appreciated.

---

<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:** [April 9, 2024, 9:53pm UTC](https://forum.codecrafters.io/t/redis-challenge-stage-hd5/62/4 "2024-04-09T21:53:35Z")

</div>

Hey @harish876,

We’ve pushed a fix that makes the logs a bit better here - it should now say something like `Received: "" (no content received)` to make it clear that the error is that we didn’t receive a response.

And re: the bug, you’re right - it is related to the handshake step. We were able to identify one bug in this section:

> <https://github.com/harish876/harish876-codecrafters-redis-go/blob/23b2c4fb3c812bbbc6394b8bcfe23d16b55eec97/pkg/server/replication.go#L81>

The `Read` call here here is assuming that it’ll only receive the `+FULLRESYNC...` response, but that’s incorrect.

After a replica sends a PSYNC, it’s supposed to receive (a) the `+FULLRESYNC` response to the PSYNC command, (b) The RDB file contents (c) any propagated commands. There’s no wait period between the sending of these values, so they might arrive all at once, or they might arrive one-by-one (in theory you could even get “partial” reads, but I don’t think that’ll apply to our tests).

The “flaky” pass you’re seeing is most likely because in that specific test run things were _just_ slow enough for those `Read` calls to return the expected messages in order. In the failure case, the first `Read` call might’ve received all 3 messages and thus the next `Read` call would’ve blocked.

Hope this helps!

And thanks so much for highlighting this - I’ll keep an eye out for similar reports and see if I can add a note to the stage instructions for “Empty RDB transfer” that makes this more obvious.

---

<div class="post-metadata">

**Author:** ![harish876](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/harish876/32/52_2.png) [@harish876](https://forum.codecrafters.io/u/harish876)\
**Post date:** [April 10, 2024, 3:09am UTC](https://forum.codecrafters.io/t/redis-challenge-stage-hd5/62/5 "2024-04-10T03:09:59Z")

</div>

Ah that makes sense. Thanks for the help

---

<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:** [April 30, 2024, 10:59pm UTC](https://forum.codecrafters.io/t/redis-challenge-stage-hd5/62/6 "2024-04-30T22:59:44Z")

</div>



---

<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, 5:52am UTC](https://forum.codecrafters.io/t/redis-challenge-stage-hd5/62/7 "2024-06-04T05:52:35Z")

</div>

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