[Django] #33826: Redis client raises exceptions in the RedisCache backend delete_many and set_many methods when used with empty keys or data

81 views
Skip to first unread message

Django

unread,
Jul 5, 2022, 12:49:07 PM7/5/22
to django-...@googlegroups.com
#33826: Redis client raises exceptions in the RedisCache backend delete_many and
set_many methods when used with empty keys or data
-----------------------------------------------+--------------------------
Reporter: Christos Kopanos | Owner: (none)
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+--------------------------
I am not sure the behavior described below is the intended (in the sense
that the code utilizing the cache backend should make sure to place those
checks introduced before calling delete_many or set_many, however looking
at the Database backend implementation similar checks do exist when
calling the delete_many method and since I jumped into this bug using the
redis backend a fix is needed I think to address this issue.

**Case**

If the 2 methods call the underlying redis client DEL and MSET commands
with
empty parameters then an exception will be thrown by the redis client:

redis.exceptions.ResponseError: wrong number of arguments for 'del'
command

and

redis.exceptions.ResponseError: Command # 1 (MSET) of pipeline caused
error: wrong number of arguments for 'mset' command

respectively.

**Steps to reproduce**

Using


{{{
USE_TZ = False
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME":
"mydatabase"}}

CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": "redis://localhost:6379",
}
}
}}}


as a settings file run a shell


{{{
./manage.py shell --settings myapp.settings
from django.core.cache import cache
cache.delete_many([])
}}}


raises exception redis.exceptions.ResponseError: wrong number of arguments
for 'del' command


{{{
cache.set_many({})
}}}


raises exception redis.exceptions.ResponseError: Command # 1 (MSET) of
pipeline caused error: wrong number of arguments for 'mset' command

--
Ticket URL: <https://code.djangoproject.com/ticket/33826>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 5, 2022, 12:53:41 PM7/5/22
to django-...@googlegroups.com
#33826: Redis client raises exceptions in the RedisCache backend delete_many and
set_many methods when used with empty keys or data
-------------------------------------+-------------------------------------
Reporter: Christos Kopanos | Owner: Christos
| Kopanos

Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 4.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Christos Kopanos):

* owner: (none) => Christos Kopanos


--
Ticket URL: <https://code.djangoproject.com/ticket/33826#comment:1>

Reply all
Reply to author
Forward
0 new messages