redis / redis-py

Redis Python client
MIT License
12.53k stars 2.5k forks source link

redisCluster can't enable RESP3 #3145

Open owanio1992 opened 6 months ago

owanio1992 commented 6 months ago

when try enable protocol=3 get error

Segmentation fault

Version: 5.0.1

Platform: Python3.10.12 on ubuntu 22.04

Description: can't set args protocol=3

reproduce:

pip3 install redis==5.0.1
python3
from redis import RedisCluster as Redis
r = Redis.from_url("redis://localhost:7000/0?protocol=2")
r.ping()
r = Redis.from_url("redis://localhost:7000/0?protocol=3")

Screenshot_20240215_155546

akx commented 6 months ago

Run with the environment variable PYTHONDEVMODE=1 to enable (among other things) the segfault handler for a better clue.

akx commented 6 months ago

Also, probably #3074.

dvora-h commented 6 months ago

Hi @owanio1992 What is your processor architecture?

owanio1992 commented 6 months ago

@dvora-h my processor architecture is x86-64 (AMD EPYC 7571)

@akx here is output with PYTHONDEVMODE=1

(nebula-ap_2024-02-16_1708077366) ubuntu@node1:/opt/nebula/venv/nebula-ap_api$ PYTHONDEVMODE=1 python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from redis import RedisCluster as Redis
>>> r = Redis.from_url("redis://localhost:7000/0?protocol=3")
Fatal Python error: Segmentation fault

Current thread 0x00007f38dff5a000 (most recent call first):
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/_parsers/hiredis.py", line 128 in read_response
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/connection.py", line 500 in read_response
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/client.py", line 553 in parse_response
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/cluster.py", line 1151 in _execute_command
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/cluster.py", line 1101 in execute_command
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/commands/core.py", line 792 in command
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/_parsers/commands.py", line 70 in initialize
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/_parsers/commands.py", line 67 in __init__
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/cluster.py", line 645 in __init__
  File "/opt/nebula/venv/venv_src/nebula-ap_2024-02-16_1708077366/lib/python3.10/site-packages/redis/cluster.py", line 488 in from_url
  File "<stdin>", line 1 in <module>

Extension modules: hiredis.hiredis (total: 1)
Segmentation fault
gerzse commented 2 months ago

Hi @owanio1992 ,

Does this still happen to you?

It might be that you have hiredis-py installed, which we recently detected to cause such segmentation faults. PR #3270 is related to this, and there is this issue open with hiredis-py: https://github.com/redis/hiredis-py/issues/188

The workaround would be to uninstall hiredis-py if you can.

gerzse commented 2 months ago

@owanio1992 ,

If you are using hiredis-py, what is your main reason to prefer this instead of the built-in RESP parser from redis-py?