Mass Insertion into Redis Docker Container

228 views
Skip to first unread message

Eric Stoces

unread,
Mar 10, 2021, 9:03:05 PM3/10/21
to Redis DB
Mass inserts fail going to redis docker container.  I tried multiple formats as described in the documentation on https://redis.io/topics/mass-insert.

Has anyone used piped data into a docker container using the redis-cli --pipe?

>ruby mass_insert.rb
"*3\r\n$3\r\nSET\r\n$4\r\nKey0\r\n$6\r\nValue0\r\n"

>ruby mass_insert.rb | docker exec -i redis-search-2 redis-cli --pipe
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 1, replies: 1
ERR unknown command `*3  $3  SET  $4  Key0  $6  Value0  `, with args beginning with:


>ruby mass_insert.rb
*3
$3
SET
$4
Key0
$6
Value0

>ruby mass_insert.rb | docker exec -i redis-search-2 redis-cli --pipe
ERR Protocol error: expected '$', got ' '
No replies for 30 seconds: exiting.
All data transferred. Waiting for the last reply...
errors: 2, replies: 1

Ankit Gupta

unread,
Mar 10, 2021, 9:33:11 PM3/10/21
to Redis DB
Hi ,

I have used mass insert using following 

cat data.txt | redis-cli --pipe

I was able to insert data using above

孙德冰

unread,
Mar 10, 2021, 9:52:48 PM3/10/21
to redi...@googlegroups.com
It looks like you have some extra spaces in your output.
⚡ root@A12668  /data/redis_fork/src  unstable cat 1.rb
puts "*3\r\n$3\r\nSET\r\n$4\r\nKey0\r\n$6\r\nValue0\r\n"
⚡ root@A12668  /data/redis_fork/src  unstable ruby 1.rb

*3
$3
SET
$4
Key0
$6
Value0
⚡ root@A12668  /data/redis_fork/src  unstable ruby 1.rb | ./redis-cli --pipe

All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 1

Eric Stoces <ewst...@gmail.com> 于2021年3月11日周四 上午10:03写道:
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/ddb11776-1d9d-49a2-8f56-2ad564398989n%40googlegroups.com.

Eric Stoces

unread,
Mar 11, 2021, 1:29:41 PM3/11/21
to Redis DB
This is what the data looks like "*3\r\n$3\r\nSET\r\n$4\r\nKey0\r\n$6\r\nValue0\r\n".  So, there are no spaces in the output.

My guess is that this has something to do with either the pipe data to the container or windows to linux issue.  So, has anyone piped to a Docker Container?

孙德冰

unread,
Mar 11, 2021, 8:27:21 PM3/11/21
to redi...@googlegroups.com
image.png
I tried it with docker, and it works.

Eric Stoces <ewst...@gmail.com> 于2021年3月12日周五 上午2:29写道:

孙德冰

unread,
Mar 11, 2021, 8:36:43 PM3/11/21
to redi...@googlegroups.com
image.png
You're right, it does have this problem on windows.

孙德冰 <sund...@gmail.com> 于2021年3月12日周五 上午9:26写道:

Eric Stoces

unread,
Mar 12, 2021, 12:52:18 PM3/12/21
to Redis DB
I installed cygwin and ran the same and it succeeded...  So I have a work around.
Reply all
Reply to author
Forward
0 new messages