2017-04-04 341 views
0

我們試圖通過redis-py包將大小爲2.3GB的pickled對象設置爲redis。遇到以下錯誤。Broken Pipe Error Redis

BrokenPipeError: [Errno 32] Broken pipe

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

我想了解根本原因。是否由於服務器端或客戶端的輸入/輸出緩衝區限制?這是由於RESP協議的限制嗎?允許將2.3 Gb的單值(字節)存儲到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。該命令發送到Redis的兩個項目如下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的服務器服務器關閉了連接,因爲值$ 2460086692違反了512 MB的協議規則
  • 當項目#2發送到Redis服務器時,我們得到Broken P由於連接已被服務器關閉,因此異常。