# Incorrect test for Replication #TU8

**URL:** <https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [April 13, 2024, 8:32am UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102 "2024-04-13T08:32:05Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnomeby](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gnomeby/32/85_2.png) [@gnomeby](https://forum.codecrafters.io/u/gnomeby)\
**Post date:** [April 13, 2024, 8:32am UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/1 "2024-04-13T08:32:05Z")

</div>

I’m stuck on Replication 17.

I’ve tried Real Redis MASTER and 1 my Redis As SLAVE.

When I sent WAIT 10 300 to the MASTER without any WRITEs before I’ve got:  
[‘REPLCONF’, ‘GETACK’, ‘\*’]  
on SLAVE and everything works fine.

Then I’ve tried my Redis as MASTER and 1 Real Redis SLAVE.  
When I sent WAIT 10 300 to the MASTER without any WRITEs before I’ve got  
the additional [‘REPLCONF’, ‘ACK’, ‘185’] from SLAVE  
and everything works fine.

But on tests I’ve sent:  
[‘REPLCONF’, ‘GETACK’, ‘\*’] to all test replicas and did not get any ACK answer

Here are my logs:

```auto
remote: [replication-17] client: $ redis-cli WAIT 3 500
remote: [your_program] ['WAIT', '3', '500']
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] [Start WAIT] at 1712997390.1653676
remote: [your_program] [STOP WAIT] at 1712997390.6666832
remote: [your_program] <- b':0\r\n'

```

---

<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 16, 2024, 12:20pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/2 "2024-04-16T12:20:30Z")

</div>

Hey @gnomeby,

Can you try setting `debug: true` in your codecrafters.yml? I think you should see more helpful logs in that case. We should be logging out the reciept of GETACK \*, and the ACKs that were sent back.

More on debug mode here: [How do I debug test failures? - CodeCrafters](https://docs.codecrafters.io/challenges/debug-test-failures#1-turn-on-debug-mode)

---

<div class="post-metadata">

**Author:** ![gnomeby](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gnomeby/32/85_2.png) [@gnomeby](https://forum.codecrafters.io/u/gnomeby)\
**Post date:** [April 16, 2024, 6:22pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/3 "2024-04-16T18:22:07Z")

</div>

With debug:

```auto
remote: [replication-17] client: $ redis-cli WAIT 3 500
remote: [replication-17] client: Sent bytes: "*3\r\n$4\r\nWAIT\r\n$1\r\n3\r\n$3\r\n500\r\n"
remote: [your_program] ['WAIT', '3', '500']
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] [Start WAIT] at 1713278386.1287766
remote: [your_program] [STOP WAIT] at 1713278386.6303675
remote: [your_program] <- b':0\r\n'
remote: [replication-17] client: Received bytes: ":0\r\n"
remote: [replication-17] client: Received RESP value: 0
remote: [replication-17] Expected 8, got 0
remote: [replication-17] Test failed
remote: [replication-17] Terminating program

```

---

<div class="post-metadata">

**Author:** ![Hacker-007](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/hacker-007/32/134_2.png) [@Hacker-007](https://forum.codecrafters.io/u/Hacker-007)\
**Post date:** [April 19, 2024, 1:14am UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/4 "2024-04-19T01:14:38Z")

</div>

I am also running into the same issue. Setting `debug: true` in the config file shows that the test replica does not respond to the `getack` commands that I send as the connection is reset. Are there any solutions on my end to this problem?

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/1X/6813103247beb58a312ec8c02dc5362dc538b00a.png)

---

<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 4, 2024, 1:16pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/5 "2024-05-04T13:16:00Z")

</div>

We’ve got to improve logs here to convey when replicas received GETACKs, and when they send ACKs back (or not). Will keep open until we’ve done this!

---

<div class="post-metadata">

**Author:** ![gnomeby](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gnomeby/32/85_2.png) [@gnomeby](https://forum.codecrafters.io/u/gnomeby)\
**Post date:** [May 4, 2024, 7:15pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/6 "2024-05-04T19:15:44Z")

</div>

Here are full logs:

```auto
remote: [replication-17] client: $ redis-cli WAIT 3 500
remote: [replication-17] client: Sent bytes: "*3\r\n$4\r\nWAIT\r\n$1\r\n3\r\n$3\r\n500\r\n"
remote: [your_program] ['WAIT', '3', '500']
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] [Start WAIT] at 1714849205.191998
remote: [your_program] [STOP WAIT] at 1714849205.6934195
remote: [your_program] <- b':0\r\n'
remote: [replication-17] client: Received bytes: ":0\r\n"
remote: [replication-17] client: Received RESP value: 0
remote: [replication-17] Expected 4, got 0
remote: [replication-17] Test failed
remote: [replication-17] Terminating program

```

and in the same time test for Replication-18 has been passed:

```auto
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: 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: [your_program] ['WAIT', '3', '2000']
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] R <- b'*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n'
remote: [your_program] [Start WAIT] at 1714849201.0465517
remote: [replication-18] replica-1: Received bytes: "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
remote: [replication-18] replica-1: Received RESP value: ["REPLCONF", "GETACK", "*"]
remote: [replication-18] Received ["REPLCONF", "GETACK", "*"]
remote: [replication-18] replica-1: $ redis-cli REPLCONF ACK 99
remote: [replication-18] replica-1: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$2\r\n99\r\n"
remote: [replication-18] Testing Replica : 2
remote: [replication-18] replica-2: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
remote: [replication-18] replica-2: Received RESP value: ["SET", "baz", "789"]
remote: [replication-18] Received ["SET", "baz", "789"]
remote: [your_program] ['REPLCONF', 'ACK', '99']
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: $ redis-cli REPLCONF ACK 99
remote: [replication-18] replica-2: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$3\r\nACK\r\n$2\r\n99\r\n"
remote: [replication-18] Testing Replica : 3
remote: [replication-18] replica-3: Received bytes: "*3\r\n$3\r\nSET\r\n$3\r\nbaz\r\n$3\r\n789\r\n"
remote: [replication-18] replica-3: Received RESP value: ["SET", "baz", "789"]
remote: [replication-18] Received ["SET", "baz", "789"]
remote: [your_program] ['REPLCONF', 'ACK', '99']
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: [your_program] [STOP WAIT] at 1714849203.0527372
remote: [your_program] <- b':2\r\n'
remote: [replication-18] client: Received bytes: ":2\r\n"
remote: [replication-18] client: Received RESP value: 2
remote: [replication-18] WAIT command returned after 2013 ms
remote: [replication-18] Test passed.

```

and it looks like your replication clients from Replication-17 tests just doesn’t reply after receiving RDB file.

---

<div class="post-metadata">

**Author:** ![malshoff](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/malshoff/32/1961_2.png) [@malshoff](https://forum.codecrafters.io/u/malshoff)\
**Post date:** [May 8, 2024, 5:36am UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/7 "2024-05-08T05:36:34Z")

</div>

Confirming this. I’m having the same problem with stage 17 and being incompatible: [Redis Replication 18: Timeout Issue - #5 by malshoff](https://forum.codecrafters.io/t/redis-replication-18-timeout-issue/208/5)

---

<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 13, 2024, 12:02pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/8 "2024-05-13T12:02:01Z")

</div>

We’ve now added logs that convey when a replica decides to respond vs. not:

 ![Screenshot 2024-05-13 at 12.52.32](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/1X/8736673ddb19bc8c42ce0452a631179c33438c63.png)

Going to close this out for now, please let us know if you still need help!

---

<div class="post-metadata">

**Author:** ![gnomeby](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gnomeby/32/85_2.png) [@gnomeby](https://forum.codecrafters.io/u/gnomeby)\
**Post date:** [May 13, 2024, 12:24pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/9 "2024-05-13T12:24:51Z")

</div>

In test for the Replication-17 step your replicas are not going to get:  
REPLCONF GETACK \*  
when master get WAIT cmd.  
and this is described in Replication-17 step.

It is clear and there would not be a problem if real REDIS behaves in the same way. But it is not. Real REDIS sends REPLCONF GETACK \* in all cases, even if it empty.

---

<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 13, 2024, 12:48pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/10 "2024-05-13T12:48:24Z")

</div>

@gnomeby our behaviour _should_ match what Redis does. We verify our tester against an official Redis server for this very purpose. Can you share more details on the differences you’re seeing? Are you able to observe this locally?

---

<div class="post-metadata">

**Author:** ![gnomeby](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gnomeby/32/85_2.png) [@gnomeby](https://forum.codecrafters.io/u/gnomeby)\
**Post date:** [May 13, 2024, 1:02pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/11 "2024-05-13T13:02:41Z")

</div>

Yes, I observed this locally when I connect my official Redis 7.2.4 (MASTER) to my python Redis (SLAVE). And I described this in the initial comment.

---

<div class="post-metadata">

**Author:** ![gnomeby](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gnomeby/32/85_2.png) [@gnomeby](https://forum.codecrafters.io/u/gnomeby)\
**Post date:** [May 13, 2024, 1:26pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/12 "2024-05-13T13:26:08Z")

</div>

I’ve rechecked behavior and found the following:

Case 1:  
Official empty Redis as MASTER  
and 1 my redis as slave

if I send WAIT 1 1 to master then MASTER responses immediately without sending REPLCONF GETACK \* to SLAVE.  
if I send WAIT 2 1 (more replicas then exists) to master then MASTER sends REPLCONF GETACK \* to SLAVEs.

So it looks like my mistake.

---

<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 13, 2024, 1:34pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/13 "2024-05-13T13:34:31Z")

</div>

Ah, yep!

For anyone else who lands here, you can confirm this with wireshark. Spawn a Redis master and connect as a replica, you’ll see that it doesn’t request ACKs if no commands are sent and the replica count is lesser than / equal to the connected count:

 ![Screenshot 2024-05-13 at 14.32.33](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/1X/aff76ff7af16e06f65c5cc0f022bc1396bb1fd66.png)

(Note that when I use `WAIT 2`, a GETACK is sent, but it isn’t when doing `WAIT 1`)

---

<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 18, 2024, 1:35pm UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/14 "2024-05-18T13:35:15Z")

</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:15am UTC](https://forum.codecrafters.io/t/incorrect-test-for-replication-tu8/102/15 "2024-06-04T02:15:55Z")

</div>

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