DISCARD without MULTI
See original GitHub issueHey folks,
I came across a weird issue today where one of our processes started raising ResponseError: DISCARD without MULTI when calling execute() on a pipeline object. As far as I can tell, this error should be impossible to receive since redis-py is supposed to take care of any discard/unwatching when using pipeline objects. This suggests a bug in redis-py not properly cleaning up after itself, although I’ve been reading the code and I don’t see yet how this is possible. I also don’t know how to reproduce the bug.
ERROR 2016-10-29 04:34:32.807 error expiring
Traceback (most recent call last):
File "dmserver.py", line 1477, in push_in_worker
redis_ops.cq_expire_items(channel_key)
File "redis_ops.py", line 129, in cq_expire_items
pipe.execute()
File "/usr/lib/python2.7/dist-packages/redis/client.py", line 2626, in execute
return execute(conn, stack, raise_on_error)
File "/usr/lib/python2.7/dist-packages/redis/client.py", line 2521, in _execute_transaction
self.immediate_execute_command('DISCARD')
File "/usr/lib/python2.7/dist-packages/redis/client.py", line 2461, in immediate_execute_command
return self.parse_response(conn, command_name, **options)
File "/usr/lib/python2.7/dist-packages/redis/client.py", line 2584, in parse_response
self, connection, command_name, **options)
File "/usr/lib/python2.7/dist-packages/redis/client.py", line 585, in parse_response
response = connection.read_response()
File "/usr/lib/python2.7/dist-packages/redis/connection.py", line 582, in read_response
raise response
ResponseError: DISCARD without MULTI
I’m using Redis 3.0.6 and redis-py 2.10.5.
Anyone seen anything like this before and have any suggestions?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
DISCARD without MULTI · Issue #795 · redis/redis-py - GitHub
I am using a threaded environment. The Redis object is shared, but the pipeline is not. Here's a simplified version of my code:...
Read more >transactions - In Redis, what happens when there is a MULTI ...
I'm curious what will happen if in one script I run MULTI and start but then the script somehow fails and I never...
Read more >DISCARD without MULTI - Google Groups
Hi everyone, I am not understanding this exception from the code below. jedis.watch(key); String value = jedis.get(key);
Read more >DISCARD - Redis
Discard all commands issued after MULTI. ... DISCARD. Syntax. DISCARD. Available since: 2.0.0; Time complexity: O(N), when N is the number of queued ......
Read more >Discards - unassigned discardable variables - Microsoft Learn
Discards are placeholder variables that are intentionally unused in application code. Discards are equivalent to unassigned variables; ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve also had this issue recently.
Let my summarise it just if anyone is also struggling.
You clearly cannot do the following:
But following is allowed:
Long story short, if you are using pipeline, each of the command is queued. If one of the queued command results with an error, you might get
DISCARD without MULTI. In my case arguments tosaddwere computed dynamically and sometimes ended up as an empty list. This was clearly an issue in my application logic.Since we keep the commands in the stack we could handle this specific case by introspecting the stack arguments and throw an error as soon as we add something there. In my case it is possible to know this sooner, without calling execute on pipeline.
What do you guys think about this?
This was fixing in redis-py 3.5.0. Forgot to close this issue when the error was resolved.