dealertrack / celery-redis-sentinel

Redis Sentinel broker and results backend for celery
http://celery-redis-sentinel.readthedocs.org/
Other
40 stars 33 forks source link

redis.exceptions.ResponseError #15

Open chanpl opened 7 years ago

chanpl commented 7 years ago

File "/lib/python3.5/site-packages/redis/client.py", line 2626, in execute return execute(conn, stack, raise_on_error) File "/lib/python3.5/site-packages/redis/client.py", line 2540, in _execute_transaction self.raise_first_error(commands, response) File "/lib/python3.5/site-packages/redis/client.py", line 2574, in raise_first_error raise r redis.exceptions.ResponseError: Command # 1 (SETEX b'celery-task-meta-84b7aefb-0487-45bf-875b-49cd5087e7e6' {"traceback": null, "status": "SUCCESS", "children": [], "task_id": "84b7aefb-0487-45bf-875b-49cd5087e7e6", "result": 11} 86400) of pipeline caused error: value is not an integer or out of range

exc, exc_info.traceback)))

Above exception is raised when I used this module to configure result backend. The SETEX looks a bit strange that timeout value is not at the 2nd position of the args.

If this module is not used, but use Celery 4.0.2 directly with Redis result backend. The SETEX looks like this: [(('SETEX', b'celery-task-meta-a11b3664-320d-4b48-a25b-154c61ea9bc7', 86400, '{"task_id": "a11 b3664-320d-4b48-a25b-154c61ea9bc7", "traceback": null, "result": 11, "status": "SUCCESS", "children": []}'), {}), (('PUBLISH', b'celery-task-meta-a11b3664-320d-4b48-a25b-154c61ea9bc7', '{"task_id": "a11b3664-320d-4b48-a25b-154c61ea9bc7", "traceback": null, "result": 11, "status": "SUCCESS", "children": []}'), {})]

chanpl commented 7 years ago

this issue is solved by using redis_class=StrictRedis in Sentinel class.

kellanburket commented 7 years ago

In order to avoid this error I changed the return value of RedisSentinelBackend.client to return get_redis_via_sentinel(redis_class=type(str('StrictRedis'), (EnsuredRedisMixin, StrictRedis), {}), **params). Is this going to cause any problems down the road for me?

chanpl commented 7 years ago

According to this document, there are little differences between Redis and StrictRedis, while SETEX is one of it.

Ref: https://pypi.python.org/pypi/redis

// SETEX: Order of ‘time’ and ‘value’ arguments reversed. //

The reason is try to support backward comparability of redis-py. I haven't do any test in older version, but at least working fine on redis-py v2.10.5 and redis v3.2