MemoryError in Redis while Pipelining

688 Views Asked by At

I am using this python script to migrate data from one ElastiCache redis instance to another. It uses the redis pipelining to migrate data in chunks.

https://gist.github.com/thomasst/afeda8fe80534a832607

But I am getting this strange error:

Traceback (most recent call last):###########                                         | ETA:  0:00:12
  File "migrate-redis.py", line 95, in <module>
    migrate()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "migrate-redis.py", line 74, in migrate
    results = pipeline.execute(False)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2593, in execute
    return execute(conn, stack, raise_on_error)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2446, in _execute_transaction
    all_cmds = connection.pack_commands([args for args, _ in cmds])
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 637, in pack_commands
    output.append(SYM_EMPTY.join(pieces))
MemoryError

There are no issues with RAM as node has 6 GB of RAM.

The Memory Profile of source redis is as follows:

used_memory:1483900120
used_memory_human:1.38G
used_memory_rss:1945829376
used_memory_peak:2431795528
used_memory_peak_human:2.26G
used_memory_lua:86016
mem_fragmentation_ratio:1.31
mem_allocator:jemalloc-3.6.0

What can be the possible cause for this ?

1

There are 1 best solutions below

1
On

From your error log, It has no relation with your redis server. The error happens in your redis client when it pack all commands into a memory buffer.

Maybe you could try to decrease the SCAN count option in your migrate-redis.py to test if it is too large to pack it.