Skip to content

Commit 900dbea

Browse files
committed
Fix off by 2 error in EXEC reply handling
The EXEC reply should have the same number of replies as there are commands in the MULTI. This line of code expected the MULTI and EXEC commands themselves to be part of the futures array, but they are not. Note that this only surfaces for Redis versions < 2.6.5, because that is when the EXECABORT error reply was introduced. Also see: antirez/redis@41f0f92.
1 parent d75ac5a commit 900dbea

File tree

3 files changed

+1
-5
lines changed

3 files changed

+1
-5
lines changed

lib/redis/pipeline.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def finish(replies)
7878
# EXEC command failed.
7979
raise exec if exec.is_a?(CommandError)
8080

81-
if exec.size < futures.size - 2
81+
if exec.size < futures.size
8282
# Some command wasn't recognized by Redis.
8383
raise replies.detect { |r| r.is_a?(CommandError) }
8484
end

test/pipelining_commands_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ def test_assignment_of_results_inside_the_block_with_errors
9393
r.pipelined do
9494
r.doesnt_exist
9595
@first = r.sadd("foo", 1)
96-
r.doesnt_exist
9796
@second = r.sadd("foo", 1)
98-
r.doesnt_exist
9997
end
10098
end
10199

test/transactions_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ def test_assignment_inside_multi_exec_block_with_immediate_command_errors
6767
r.multi do |m|
6868
m.doesnt_exist
6969
@first = m.sadd("foo", 1)
70-
m.doesnt_exist
7170
@second = m.sadd("foo", 1)
72-
m.doesnt_exist
7371
end
7472
end
7573

0 commit comments

Comments
 (0)