Redis: Scala: Missing rdb file on stage #JZ6

I’m currently using Scala to complete the Redis challenge and am running into what seems to be an inconsistency with the running on the test runners vs locally. I am currently at the stage of writing an RDB parser.

I execute a command like so locally:

./your_program.sh --dir /tmp/rdbfiles3521434412 --dbfilename strawberry.rdb

And my program processes the 2 parameters correctly. I’ve verified this with logging. But when run on the test runner the parameters don’t appear to be acted upon in the same way even though they are present as arguments.

I thought it might be related to annotation processing and reflection. I am using the picoli library for command line parsing. So I removed the annotations and manually parsed the command line arguments only to find that the file does not exist according to the Java NIO libraries:

remote: [tester::#JZ6] Running tests for Stage #JZ6 (RDB Persistence - Read a key)
remote: [tester::#JZ6] Created RDB file with single key: "apple"
remote: [tester::#JZ6] $ ./your_program.sh --dir /tmp/rdbfiles682173698 --dbfilename mango.rdb
remote: [your_program] 21:35:54.379 WARN  codecrafters_redis.Server$ - Got args [--dir, /tmp/rdbfiles682173698, --dbfilename, mango.rdb]
remote: [your_program] 21:35:54.474 INFO  codecrafters_redis.Server - Logs from your program will appear here!
remote: [your_program] 21:35:54.549 WARN  codecrafters_redis.RDBReader$ - mango.rdb (/app/mango.rdb) does not exist
remote: [tester::#JZ6] client: $ redis-cli KEYS *
remote: [your_program] 21:35:54.637 INFO  codecrafters_redis.Server - Got client: RedisClient(2ca35173-35ef-46de-98cc-60100e0e6f7f)
remote: [your_program] 21:35:54.659 INFO  c.resp.DataType$Array$ - Reading array of 2 entries
remote: [your_program] 21:35:54.668 INFO  codecrafters_redis.CommandParser$ - Got 2 command strings
remote: [your_program] 21:35:54.669 INFO  codecrafters_redis.CommandParser$ - Got command: KEYS *
remote: [your_program] 21:35:54.684 INFO  codecrafters_redis.CommandParser$ - Giving response: Array(Vector())
remote: [tester::#JZ6] Expected array with at least 1 element, got 0 elements
remote: [tester::#JZ6] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
remote: [your_program] 21:35:54.696 INFO  codecrafters_redis.Server - No errors encountered
remote: [your_program] 21:35:54.696 INFO  codecrafters_redis.Server - Closed client Socket[addr=/127.0.0.1,port=49058,localport=6379]

It’s my understanding that the file should exist for this test since, if it doesn’t, there will be 0 elements in the database (as there is nothing to load).

I use the method Files.notExists for reference.

@LyndonArmitage I think this might be an issue with how the final path is computed. The expected path here would be /tmp/rdbfiles682173698/mango.rdb. The logs above say /app/mango.rdb.

Ah that makes sense. I am not sure why I was under the impression they were unrelated to each other. Sorry for the false report!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.