# Unable to resolve "Command processing" (#YG4)

**URL:** <https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [November 16, 2024, 1:12pm UTC](https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967 "2024-11-16T13:12:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![matiasgarcia](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/matiasgarcia/32/2959_2.png) [@matiasgarcia](https://forum.codecrafters.io/u/matiasgarcia)\
**Post date:** [November 16, 2024, 1:12pm UTC](https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967/1 "2024-11-16T13:12:58Z")

</div>

I’m stuck on Stage #YG4

I believe I am facing some race conditions when sending the commands to the replicas, but I am having a hard time to understand where’s the problem.

Here are my logs:

```auto
tester::#HD5] [handshake] Received "FULLRESYNC b8b6e5ee4a5e6b1628df86d459349fd4acbbbe37 0"
[tester::#HD5] [handshake] Reading RDB file...
[your_program] << $88
[your_program] REDIS0011� redis-ver7.2.0�
[your_program] redis-bits�@�ctime��eused-mem°�aof-base���n;���Z�
[your_program] push
[tester::#HD5] [handshake] replica-3: 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"
[tester::#HD5] [handshake] Received RDB file
[tester::#HD5] [test] client: $ redis-cli SET foo 123
[tester::#HD5] [test] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
[your_program] >> "*3 $3 SET $3 foo $3 123"
[your_program] <<[fwd][127.0.0.1:45902] "*3 $3 SET $3 foo $3 123"
[your_program] <<[fwd][127.0.0.1:45908] "*3 $3 SET $3 foo $3 123"
[your_program] <<[fwd][127.0.0.1:45912] "*3 $3 SET $3 foo $3 123"
[your_program] << "+OK "
[tester::#HD5] [test] client: Received bytes: "+OK\r\n"
[tester::#HD5] [test] client: Received RESP simple string: "OK"
[tester::#HD5] [test] Received "OK"
[tester::#HD5] [test] client: > SET bar 456
[tester::#HD5] [test] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\n456\r\n"
[your_program] >> "*3 $3 SET $3 bar $3 456"
[your_program] <<[fwd][127.0.0.1:45902] "*3 $3 SET $3 bar $3 456"
[your_program] <<[fwd][127.0.0.1:45908] "*3 $3 SET $3 bar $3 456"
[your_program] <<[fwd][127.0.0.1:45912] "*3 $3 SET $3 bar $3 456"
[your_program] << "+OK "
[tester::#HD5] [test] client: Received bytes: "+OK\r\n"
[tester::#HD5] [test] client: Received RESP simple string: "OK"
[tester::#HD5] [test] Received "OK"
[tester::#HD5] [test] client: > SET baz 789
[tester::#HD5] [test] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
[your_program] >> "*3 $3 SET $3 baz $3 789"
[your_program] <<[fwd][127.0.0.1:45902] "*3 $3 SET $3 baz $3 789"
[your_program] <<[fwd][127.0.0.1:45908] "*3 $3 SET $3 baz $3 789"
[your_program] <<[fwd][127.0.0.1:45912] "*3 $3 SET $3 baz $3 789"
[your_program] << "+OK "
[tester::#HD5] [test] client: Received bytes: "+OK\r\n"
[tester::#HD5] [test] client: Received RESP simple string: "OK"
[tester::#HD5] [test] Received "OK"
[tester::#HD5] [test] Testing Replica: 1/3
[tester::#HD5] [test] replica-1: Expecting "SET foo 123" to be propagated
[tester::#HD5] Received: "ET\r\n$3\r\nfoo\r\n$3\r\n123*3\r\n$3\r\nSE"
[tester::#HD5] ^ error
[tester::#HD5] Error: Expected \r\n after 3 bytes of data in bulk string
[tester::#HD5] Test failed
[tester::#HD5] Terminating program
[tester::#HD5] Program terminated successfully

```

And here’s a snippet of my code:

> <https://github.com/matiasgarcia/node-redis/commit/4035f2713b750117145740d457b786cbd083bf95>

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 16, 2024, 2:09pm UTC](https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967/2 "2024-11-16T14:09:43Z")

</div>

Hi @matiasgarcia, I tried running your code against the previous stages, but it’s no longer passing **#zn8 Single-replica propagation**.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/9/96ae84f13b1cbc1bb3b70ddc40778a9b5ad9f58e.jpeg)

Suggestions:

1. Use [our CLI](https://docs.codecrafters.io/cli/installation) to test against previous stages by running:

```auto
codecrafters test --previous

```

1. Focus on fixing the early stages first, as later stages depend on them.

---

<div class="post-metadata">

**Author:** ![matiasgarcia](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/matiasgarcia/32/2959_2.png) [@matiasgarcia](https://forum.codecrafters.io/u/matiasgarcia)\
**Post date:** [November 18, 2024, 12:50pm UTC](https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967/3 "2024-11-18T12:50:19Z")

</div>

Hi! I fixed the bug so I could make progress, but stuck on the replconf ack. Not really understand whats going on, it seems a race condition keeps triggering from time to time. Any hints?

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 24, 2024, 4:02pm UTC](https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967/5 "2024-11-24T16:02:36Z")

</div>

Sorry the delayed response! I added a log here:

```diff
function receiveCommands(connection: net.Socket) {
  connection.on("data", (stream) => {
    const commands = collectCommands(stream);
    commands.forEach((c) => {
+ console.debug(`⛳`, c.toString("ascii"));
      processCommand(c, connection);
    });
  });
}

```

Looks like the RDB file sent by the master wasn’t properly handled:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/d/df3a1dc71a3784b16357fbdf8f2d5289ca727d09.jpeg)

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [December 1, 2024, 4:24pm UTC](https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967/7 "2024-12-01T16:24:16Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<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:** [December 6, 2024, 4:24pm UTC](https://forum.codecrafters.io/t/unable-to-resolve-command-processing-yg4/2967/8 "2024-12-06T16:24:48Z")

</div>

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