# YG4，client get command before propagation set command， so get ""

**URL:** <https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [March 13, 2025, 3:55am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610 "2025-03-13T03:55:38Z")\
**Posts on this page:** 8\
**Page:** 2

<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:** [March 14, 2025, 9:40am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/24 "2025-03-14T09:40:22Z")

</div>

> and also ， why can i pass xv6

Could you clarify what you mean?

---

<div class="post-metadata">

**Author:** ![show1999](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/show1999/32/6637_2.png) [@show1999](https://forum.codecrafters.io/u/show1999)\
**Post date:** [March 14, 2025, 10:03am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/25 "2025-03-14T10:03:44Z")

</div>

@andy1li  
Yes, has anyone told you that you’re smart? Love you. Let me explain what you mean. You’re saying that the `readLine` command does indeed block the main thread until it encounters a newline character. Since the empty RDB file does not end with a newline, it remains blocked indefinitely. As a result, the program cannot proceed further and cannot start the replica to listen for client requests. Therefore, when the client requests the replica, a connection refused error occurs. Because of this error, the tester determines that this phase has failed and attempts to terminate the replica’s main thread. This action causes `readLine` to stop blocking and continue running, printing out “part3.” Additionally, before the main thread is actually terminated, it will continue to run for a while until it is fully terminated. (How long it runs depends on how quickly it is terminated.

am i right？  
appreciate it ❤

---

<div class="post-metadata">

**Author:** ![show1999](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/show1999/32/6637_2.png) [@show1999](https://forum.codecrafters.io/u/show1999)\
**Post date:** [March 14, 2025, 10:15am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/26 "2025-03-14T10:15:25Z")

</div>

What I meant earlier was why XV6 would pass. Now I realize it’s because XV6 does not have a client attempting to connect to the replica. Additionally, in XV6, the master sends data to the replica, and this data includes a newline character, which releases the blocking caused by `readLine` .

---

<div class="post-metadata">

**Author:** ![show1999](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/show1999/32/6637_2.png) [@show1999](https://forum.codecrafters.io/u/show1999)\
**Post date:** [March 14, 2025, 11:18am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/27 "2025-03-14T11:18:46Z")

</div>

are you there bro @andy1li

If my previous understanding is correct, then let’s continue and return to my initial question: how to ensure that the `set` command in propagation is executed before the `get` request from clients. My discovery is that it is neither necessary nor possible to guarantee this. This can also be proven by the design of the test cases. If the `get` command is executed first and does not retrieve a value, it can simply retry a few times. (The reason I didn’t trigger the retry mechanism earlier was that my code had an issue—a null pointer caused it to terminate directly. So, I just need to add a non-null check to fix it.)

---

<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:** [March 14, 2025, 11:25am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/30 "2025-03-14T11:25:08Z")

</div>

> My discovery is that it is neither necessary nor possible to guarantee this.

You’re absolutely right!

If you’d like to explore further, here’s the tester code for **#YG4 Command Processing** :

> <https://github.com/codecrafters-io/redis-tester/blob/main/internal/test_repl_replica_cmd_processing.go>

---

<div class="post-metadata">

**Author:** ![show1999](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/show1999/32/6637_2.png) [@show1999](https://forum.codecrafters.io/u/show1999)\
**Post date:** [March 14, 2025, 11:31am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/31 "2025-03-14T11:31:05Z")

</div>

ok ok @andy1li  
i have no questions right now  
you are so good and patient and smart  
appreciate your help very much  
😀

---

<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:** [March 14, 2025, 11:33am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/32 "2025-03-14T11:33:12Z")

</div>

Glad I could help! Feel free to start a new topic if you run into other issues.

---

<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:** [March 19, 2025, 11:33am UTC](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610/33 "2025-03-19T11:33:38Z")

</div>

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

[Previous page](https://forum.codecrafters.io/t/yg4-client-get-command-before-propagation-set-command-so-get/6610.md?page=1)
