Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOF file and RDB file as the source of Redis Mass insertion #9717

Open
hwware opened this issue Nov 1, 2021 · 3 comments
Open

AOF file and RDB file as the source of Redis Mass insertion #9717

hwware opened this issue Nov 1, 2021 · 3 comments

Comments

@hwware
Copy link
Collaborator

hwware commented Nov 1, 2021

The problem/use-case that the feature addresses

I found some aof file and rdb file can not import into Redis as Mass Insertion.

case 1: When I add aof-use-rdb-preamble yes in the Redis.conf and run Redis server sometime,
Redis will save 188242 key/value pair, then I stop the Redis server.

       Later, when I run the command:  redis-cli -h ipaddress -p portNumber --pipe   XXX.aof
       and want to import the 188242 key/value pair into Redis, I got following error:

image

        I am not sure if the error is due to the aof-use-rdb-preamble yes config parameter or because too many key/value pairs 
        in the aof file,

case 2: Now it looks like Redis do not supprt rdb file as the source of Mass insertion, if we could support this feature
in the future version?

Thanks

@oranagra
Copy link
Member

oranagra commented Nov 2, 2021

Doing this would require for redis-cli to parse the RDB file and compose RESTORE commands.
I think there are plenty of tools that do that already.
Maybe it would be nice for redis-cli to do that too (although we probably won't do that very efficiently, i.e. pipeline and multiple clients, etc).
In order to do that we need to either build a basic RDB parser inside redis-cli, at least the global structure, not the keys / types themselves (not a wise idea), or better yet, change rdb.c so that it can be compiled as a library and serve other applications that want to parse RDB files.
We do have a plan do do that (librdb) in the future, but not in the next version.
@yoav-steinberg FYI.

@leonchen83
Copy link
Contributor

leonchen83 commented Feb 2, 2022

hi @hwware
there are some external tools can do this job. first install redis-rdb-cli
step 1. split aof-use-rdb-preamble file to rdb file and aof file

rcut -s ./aof-use-rdb-preamble.aof -r ./dump.rdb -a ./appendonly.aof

step 2. convert rdb file to dump format

rct -f dump -s ./dump.rdb -o ./dump.aof -r

step 3. use redis-cli to do mass insertion

cat ./dump.aof | /redis/src/redis-cli -p 6379 --pipe
cat ./appendonly.aof | /redis/src/redis-cli -p 6379 --pipe

@hwware
Copy link
Collaborator Author

hwware commented Feb 2, 2022

Thanks, I will take a look and try it.

@oranagra oranagra added this to backlog in 7.2 <obsolete> via automation Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants