codecrafters-io / build-your-own-redis

Definition for the redis challenge.
https://app.codecrafters.io/courses/redis/overview
MIT License
108 stars 30 forks source link

Command Processing Stage #152

Open kushal0511-not opened 4 months ago

kushal0511-not commented 4 months ago

I passed this stage(Command Processing Stage ) earlier now while running test for next stage it is again failing for Command processing stage I have just added 1 line (conn.Write()) in case REPLCONF. i tried without changing code , It passes sometimes but most of times it is failing.

remote: [replication-13] PSYNC ? -1 received.
remote: [replication-13] +FULLRESYNC 20lvbc0fgoe7n06a4slgtvgq1303t8506s6sc2pm 0 sent.
remote: [replication-13] RDB file sent.
remote: [replication-13] $ redis-cli SET foo 123
remote: [replication-13] $ redis-cli SET bar 456
remote: [replication-13] $ redis-cli SET baz 789
remote: [replication-13] Getting key foo
remote: [replication-13] $ redis-cli GET foo
remote: [replication-13] 123 received.
remote: [replication-13] Getting key bar
remote: [replication-13] $ redis-cli GET bar
remote: [replication-13] 
remote: [replication-13] Assertion failed, retrying... (Attempt 2/5)
remote: [replication-13] 
remote: [replication-13] $ redis-cli GET bar
remote: [replication-13] 
remote: [replication-13] Assertion failed, retrying... (Attempt 3/5)
remote: [replication-13] 
remote: [replication-13] $ redis-cli GET bar
remote: [replication-13] 
remote: [replication-13] Assertion failed, retrying... (Attempt 4/5)
remote: [replication-13] 
remote: [replication-13] $ redis-cli GET bar
remote: [replication-13] 
remote: [replication-13] Assertion failed, retrying... (Attempt 5/5)
remote: [replication-13] 
remote: [replication-13] $ redis-cli GET bar
remote: [replication-13] 
remote: [replication-13] resp: invalid syntax
remote: [replication-13] Test failed
remote: [replication-13] Terminating program
remote: [replication-13] Program terminated successfully
linear[bot] commented 4 months ago

CC-1092 Command Processing Stage

naqet commented 3 months ago

I have the same issue. Sometimes it passes and sometimes it doesn't (I use golang).

I use goroutines to accept connections and read messages and in case there is command that should be sent also to the replication server, I have another goroutine running waiting for channel to have value with command pushed in.

Every other test passes without any problems using this approach, but with this one I have been stuck for several hours now.

Also for some reason, sometimes the first SET command is not an ARRAY but a bulk string with some weird value.

image
rohitpaulk commented 3 months ago

@naqet the bulk string there is the RDB file from the handshake, which should've been read before starting to listen for propagated commands. Looks like you eventually passed the stage, do you happen to remember what the issue was?

@kushal0511-not we've improved logs so you shouldn't see the cryptic "resp: invalid syntax" log anymore, you should see a more informative log.

Still think we can improve logs more here, will keep open until we've got that done