codecrafters-io / build-your-own-redis Goto Github PK
View Code? Open in Web Editor NEWDefinition for the redis challenge.
Home Page: https://app.codecrafters.io/courses/redis/overview
License: MIT License
Definition for the redis challenge.
Home Page: https://app.codecrafters.io/courses/redis/overview
License: MIT License
For testing the WAIT command: WAIT numreplicas timeout, when the number of numreplicas is reached, it can be returned, and any value from numreplicas to the maximum number of replicas is possible. However, the testing task requires reaching the maximum number of replicas to consider it the correct testing logic.
Specific command information can be viewed at this website address:https://redis.io/commands/wait/
This applies to all challenges - When an anti-cheat stage fails, we must say "Please contact [email protected] if you think this is an error"
remote: anti-cheat (ac1) failed.
remote: Are you sure you aren't running this against the actual Redis?
When we reuse a connection to send multiple commands, we still emit logs like this:
$ redis-cli SET a b
$ redis-cli SET b c
This can be misleading, giving the impression that these commands will be sent by different connections.
Thanks to @rsalmei for pointing this out!
rdb persistence stage 1(read config from arg) doesn't create corresponding rdb file, is it intended?
In stage 2 I implemented the server to crash when there's no rdb file but the argument is supplied.
I was figuring out why I was getting os error 2(no file) error for a while and I realized the test was failing at stage 1, not 2.
The tester is "right" here in the sense that if a file doesn't exist, the program must write it when a flush occurs.
We have two options here:
(a) is a more "true" implementation, (b) is less confusing but still lets people deal with .rdb
files and learn about them.
For instance every time I try to submit stage 3 for Redis for C++, I keep getting "undefined reference to pthread_create". I have the header files and all of the dependencies installed, so I am just confused why this keeps happening when I try to push to origin master. Is there something completely obvious I am missing?
Thanks for @SamirOsAbdalla for reporting!
Instead of just saying "Length mismatch", let's say:
Expected 28 bytes, received 24 bytes
Expected: ....
Received: ...
We might also be able to re-use https://github.com/codecrafters-io/tester-utils/blob/master/bytes_diff_visualizer/bytes_diff_visualizer.go in some way, but probably not needed here since there's no non-ascii characters involved
Let's see if we can include the received response somewhere?
Thanks to @lipinskipawel for pointing this out!
Im having trouble with syncronization in replication command processing
I have one thread that is listening for commands (like the sets) from the master, and another that is listening for commands sent directly to my replica
Sometimes the get from the test comes before I can process the set from the master. What is the recommended approach to syncronize that?
You can see I get the first SET, then I get both GETs, and only then I get the rest of the SETs
I think we need to be either sleeping for a bit before running the GET
commands, or we should retry them for a certain time period. The user's implementation seems correct from a practical perspective, it's expected that there might be a small delay between a command being propagated and it being applied on the client.
In the RDB extension, since we rely on a third-party parser, our error messages aren't very helpful.
Example:
Error while parsing RDB file : unexpected EOF
Just like we do with RESPClient, we should write our own parser that can generate friendly error messages.
Thanks to @knusth for highlighting this!
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] Running tests for Replication > Stage #11: Single-replica propagation
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] $ ./spawn_redis_server.sh --port 6379
Feb 20 05:47:46 d89d927b6e6378 vector [your_program] Logs from your program will appear here!
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] $ redis-cli PING
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] PONG received.
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] $ redis-cli REPLCONF listening-port 6380
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] OK received.
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] $ redis-cli PSYNC ? -1
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] FULLRESYNC 64df12bbf8304c23b900d67ec4171016abcd1234 0 received.
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] Successfully received RDB file from master.
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] Setting key foo to 123
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] $ redis-cli SET foo 123
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] Setting key bar to 456
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] $ redis-cli SET bar 456
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] Setting key baz to 789
Feb 20 05:47:46 d89d927b6e6378 vector [replication-11] $ redis-cli SET baz 789
Feb 20 05:47:46 d89d927b6e6378 vector [your_program] Role of calling redis type: master
Feb 20 05:47:46 d89d927b6e6378 vector [your_program] arraySize = 3, the string to print: 3
Feb 20 05:47:46 d89d927b6e6378 vector [your_program]
Feb 20 05:47:46 d89d927b6e6378 vector [your_program] *3
Feb 20 05:47:46 d89d927b6e6378 vector [your_program]
Feb 20 05:47:46 d89d927b6e6378 vector error panic: runtime error: index out of range [0] with length 0
Feb 20 05:47:46 d89d927b6e6378 vector goroutine 301 [running]:
Feb 20 05:47:46 d89d927b6e6378 vector github.com/codecrafters-io/redis-tester/internal.FakeRedisNode.readAndAssertMessagesWithSkip({0xc0000126b0, 0xc0000126b8, 0xc00038aa80, {0x0, 0x0}}, {0xc0000b3e58, 0x3, 0x3}, {0x6e012c, 0x6}, ...)
/home/runner/work/redis-tester/redis-tester/internal/util.go:399 +0x315
Feb 20 05:47:46 d89d927b6e6378 vector github.com/codecrafters-io/redis-tester/internal.testReplMasterCmdProp(0xc00038c4e0)
/home/runner/work/redis-tester/redis-tester/internal/test_repl_master_cmd_prop.go:55 +0x88f
Feb 20 05:47:46 d89d927b6e6378 vector github.com/codecrafters-io/tester-utils.testRunner.Run.func1()
/home/runner/go/pkg/mod/github.com/codecrafters-io/[email protected]/test_runner.go:63 +0x2e
Feb 20 05:47:46 d89d927b6e6378 vector created by github.com/codecrafters-io/tester-utils.testRunner.Run
/home/runner/go/pkg/mod/github.com/codecrafters-io/[email protected]/test_runner.go:62 +0x35b
Feb 20 05:47:46 d89d927b6e6378 vector Failed to run tester: exit status 2
Feb 20 05:47:46 d89d927b6e6378 vector error CodeCrafters internal error: exit status 2
Currently we don't check the time elapsed when the WAIT
command is supposed to return early.
But, as highlighted by @andy1li, this might lead to cases where user never implements WAIT
properly, just sleeps for time_duration
, and returns.
This can be mitigated by adding checks on elapsed_time
in cases where WAIT
returns early.
Thanks to @Jyuart for reporting this!
Since we're implementing INFO
in the replication extension now, let's find another command that a user is unlikely to implement.
As pointed out by @LakshyaMittal3301, in the later stages, the instructions say that the response when a blocking read times out is a nil bulk string ($3\r\nnil\r\n
). This is "nil" (a string), not a nil value.
The nil value representation of a bulk string is as follows $-1\r\n
.
The stage instructions should be updated to reflect this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.