redis-rb: _write_to_socket is changing input, which breaks write
This code is amending the input of the data
And so is this code:
Simplest fix here is simply to stop the slice! call in _write_to_socket
This is very urgent @byroot latest release is broken. Ideally we should have some sort of test to catch this.
End result is that if you are lucky, partial things are shipped to redis, if you are unlucky stuff explodes on:
NoMethodError: undefined method `bytesize' for nil:NilClass
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/connection/ruby.rb:103:in `block in write'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/connection/ruby.rb:102:in `loop'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/connection/ruby.rb:102:in `write'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/connection/ruby.rb:394:in `write'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:284:in `block in write'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:263:in `io'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:282:in `write'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:240:in `block (3 levels) in process'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:234:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:234:in `block (2 levels) in process'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:384:in `ensure_connected'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:233:in `block in process'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:320:in `logging'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:232:in `process'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/redis-4.2.3/lib/redis/client.rb:126:in `call'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (10 by maintainers)
Commits related to this issue
- Stop mutating the string received in SocketMixin#write Ref: #962 Ref: #961 — committed to redis/redis-rb by byroot 4 years ago
So I wrote the following benchmark:
On 2.7.1 it get:
The difference is so big that I can hardly believe it.
Seems like I did…
We need to copy that buffer in
write(), withdata = data.b.