2017-04-04 15 views
0

redis-pyパッケージを使用してサイズ2.3GBのpickledオブジェクトをredisに設定しようとしています。次のエラーが発生しました。壊れたパイプエラーRedis

BrokenPipeError: [Errno 32] Broken pipe

redis.exceptions.ConnectionError: Error 104 while writing to socket. Connection reset by peer.

根本原因を理解したいと思います。サーバー側とクライアント側の入出力バッファ制限によるものですか?それはRESPプロトコルの制限によるものですか? 2.3Gbの単一値(バイト)はRedisに保存できますか?

import redis

r = redis.StrictRedis(host='10.X.X.X', port=7000, db=0)

pickled_object = pickle.dumps(obj_to_be_pickled)

r.set('some_key', pickled_object)

クライアント側のエラー

BrokenPipeError: [Errno 32] Broken pipe

/usr/local/lib/python3.4/site-packages/redis/connection.py(544)send_packed_command()

self._sock.sendall(item)

サーバー側のエラー

31164:M 04 Apr 06:02:42.334 - Protocol error from client: id=95 addr=10.2.130.144:36120 fd=11 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=16384 qbuf-free=16384 obl=42 oll=0 omem=0 events=r cmd=NULL

31164:M 04 Apr 06:07:09.591 - Protocol error from client: id=96 addr=10.2.130.144:36139 fd=11 name= age=9 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=40 qbuf-free=32728 obl=42 oll=0 omem=0 events=r cmd=NULL

Redisのバージョン:3.2.8/64ビット

答えて

0

Redisの文字列データ入力することができますモスにいるt 512MB。

1

問題は、データサイズがRedisに渡されていることです。 2つの項目がRESP規格

項目#1

b'*3\r\n$3\r\nSET\r\n$8\r\nsome_key\r\n$2460086692\r\n' 

Where 
    *3   - indicates RESP array of three elements 
    \r\n   - indicates the RESP Carriage return Line Feeder(separator) 
    $3   - indicates Bulk string of length 3 bytes(here it is 'SET') 
    $8   - indicates Bulk String of length 8 bytes(he it is 'some_key') 
    $2460086692 - indicates Bulk String of length 2460086692 bytes (the length of value 2460 MB to be passed to Redis as next item) 

項目#2

b'\x80\x03csklearn.ensemble.forest\nRandomForestC... 

Here item #2 indicates the actual data 
  • #1命令はRedisのサーバーに渡された瞬間の項目を以下のようにコマンドはRedisのに送信されます、サーバーは$ 2460086692の値が512 MBのプロトコルルールに違反したため接続を終了しました
  • 項目2がRedis Serverに送信されると、Broken P接続がサーバーによって既に閉じられているため、ipe例外が発生します。
関連する問題