GithubHelp home page GithubHelp logo

codecrafters-io / build-your-own-redis Goto Github PK

View Code? Open in Web Editor NEW
102.0 102.0 30.0 995 KB

Definition for the redis challenge.

Home Page: https://app.codecrafters.io/courses/redis/overview

License: MIT License

C 9.39% Shell 15.23% Clojure 8.87% Crystal 2.43% C# 1.74% Elixir 6.35% Go 2.80% Haskell 3.40% Java 6.44% JavaScript 1.62% PHP 3.18% Python 2.04% Ruby 3.40% Rust 3.23% Makefile 0.08% Swift 0.08% Dockerfile 19.36% CMake 1.09% C++ 9.28%

build-your-own-redis's People

Contributors

beplay avatar libmartinito avatar nikandfor avatar nixypanda avatar rcardenes avatar redjonzaci avatar rohitpaulk avatar ryan-gang avatar sarupbanskota avatar thetasinner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

build-your-own-redis's Issues

WAIT with no commands has logical issues with testing

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/

Improve anti-cheat message

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?

Misleading logs when reusing a connection

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 - handle "Stage 1 doesn't create file" confusion

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) Keep existing tester behaviour, and add a comment noting this
  • (b) Just create an empty .rdb file, so that users don't have to deal with this

(a) is a more "true" implementation, (b) is less confusing but still lets people deal with .rdb files and learn about them.

C++ build doesn't include pthread?

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!

Account for processing delay in replication / command processing stage

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?

image

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.

Better errors for RDB parsing

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!

panic in single-replica propagation stage

Screenshot 2024-02-20 at 09 35 12
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

Add more checks on elapsed time in `test_wait.go`

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.

Improve anti-cheat stage

Since we're implementing INFO in the replication extension now, let's find another command that a user is unlikely to implement.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.