Problem with a testcase in #YD3

The testcase failure logs:

[tester::#YD3] [test] master: > REPLCONF GETACK *
[tester::#YD3] Received: "" (no content received)
[tester::#YD3]            ^ error

But when I run my code there clearly is some content. Also I’ve used “sudo tcpdump -i lo0 -X port 6379 or port 6380” to check the TCP traffic and there is also some content there. Here is the link to the repository with the code: GitHub - danilovict2/go-redis

I’ll take a look by the end of the week.

Hi @danilovict2 , I tried running your code against the previous stages, but it’s no longer passing Stage #YG4 (Replication - Command Processing).

Suggestions:

  1. Use our CLI to test against previous stages by running:
codecrafters test --previous
  1. Focus on fixing the early stages first, as later stages depend on them.

Hi, I’ve fixed the previous tests you mentioned, but now previous tests fail on #hd5 and the current tests still mismatch the output I have with my on #hd5 are:
[tester::#HD5] Expected command to be “set”, got “ping”
[tester::#HD5] Test failed
But when I test it on my own, nothing like this happens, and propagation seems to work fine as the keys are set in all the replicas.

Test cases on this extension are very inconsistent. I’m currently stuck on stage #YD3 and last time I asked this admin or whoever the guy is told me to make previous stages pass. This, however, is impossible because every time I run the code I get different outputs from the tests. When I run

codecrafters test --previous

or

codecrafters test

Three possibilities happened so far:

  1. All the tests passed but when I try to submit #YD3 or #YG4 fail
  2. #YG4 fails with these errors:
    [tester::#YG4] [test] Getting key foo
    [tester::#YG4] [test] client: $ redis-cli GET foo
    [tester::#YG4] [test] Retrying… (1/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (2/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (3/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (4/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (5/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] Expected simple string or bulk string, got NIL
    [tester::#YG4] Test failed (try setting ‘debug: true’ in your codecrafters.yml to see more details)
  3. #YD3 fails with these errors:
    [tester::#YD3] [test] master: > REPLCONF GETACK *
    [tester::#YD3] Received: “” (no content received)
    [tester::#YD3] ^ error
    [tester::#YD3] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
    [tester::#YD3] Test failed (try setting ‘debug: true’ in your codecrafters.yml to see more details)

Of course, when I test locally everything works as expected, and when I check tcp connections they are all there. Here is the link to my github in case anyone has any solutions to this (though I’m sure it’s not my fault):

Hi @danilovict2, the issue is likely caused by race conditions, which can result in inconsistent outputs across multiple runs.

One common cause of race conditions for replicas is when handshaking with the master overlaps with accepting client connections simultaneously:

Could you try ensuring that the handshake is fully completed before accepting client connections?

Just for context, our tester is tested rigorously against the official Redis server, so the likelihood of variability originating from our tester is minimal.

1 Like

i am facing the same issue,

Could you enlighten me on how exactly I should do that?

Sure! Just a heads-up—I’m also a beginner in Go, so take my suggestions with a grain of salt.

  1. s.connectToMaster should NOT be run as a goroutine.
  2. Once the handshake is complete, you can run the listener for the connection to the master as a goroutine.
  3. Make other necessary adjustments to your code.

Feel free to post here if you get stuck.

Tried that and it didn’t work

@danilovict2 Are you still encountering the same issue, or do the logs indicate something different now?

Test cases on this extension are very inconsistent. I’m currently stuck on stage #YD3 and last time I asked this admin or whoever the guy is told me to make previous stages pass. This, however, is impossible because every time I run the code I get different outputs from the tests. When I run

codecrafters test --previous

or

codecrafters test

Three possibilities happened so far:

  1. All the tests passed but when I try to submit #YD3 or #YG4 fail
  2. #YG4 fails with these errors:
    [tester::#YG4] [test] Getting key foo
    [tester::#YG4] [test] client: $ redis-cli GET foo
    [tester::#YG4] [test] Retrying… (1/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (2/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (3/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (4/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] [test] Retrying… (5/5 attempts)
    [tester::#YG4] [test] client: > GET foo
    [tester::#YG4] Expected simple string or bulk string, got NIL
    [tester::#YG4] Test failed (try setting ‘debug: true’ in your codecrafters.yml to see more details)
  3. #YD3 fails with these errors:
    [tester::#YD3] [test] master: > REPLCONF GETACK *
    [tester::#YD3] Received: “” (no content received)
    [tester::#YD3] ^ error
    [tester::#YD3] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
    [tester::#YD3] Test failed (try setting ‘debug: true’ in your codecrafters.yml to see more details)

Of course, when I test locally everything works as expected, and when I check tcp connections they are all there. Here is the link to my github in case anyone has any solutions to this (though I’m sure it’s not my fault):

Still have the same issue, but I don’t have a premium so the challenge has run out for me