debasishg / scala-redis

A scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side.
1.02k stars 219 forks source link

Test case for fix-format-batch, demonstrating issue with keys containing single- or double-quotes #290

Closed noahlz closed 3 years ago

noahlz commented 3 years ago

Some of our data, being capital market securities, contains single quotes. For example Ollie's Bargain Outlet (OLLI).

Batched Pipeline doesn't quite handle this and it fails with ERR Protocol error: unbalanced quotes in request

noahlz commented 3 years ago

I'm trying to reproduce other errors I'm seeing such as

Exception: ERR value is not a valid float Exception: ERR syntax error

It seems to have something to do with handling of Array[Byte] data and/or escaping special characters in keys

noahlz commented 3 years ago

I'm having trouble producing a test case, but here is RedisClient logging of the command that errors:

c.r.RedisClient C: ZADD 61806dc10da5a973534d9198:i221515:PIT:3 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Financial\xf3 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Communication Service\xf3 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Industrial\xf3 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Consumer Staple\xf3 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Information Technolog\xf9 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Consumer Discretionar\xf9 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Material\xf3 0.0 \x03\x0161806dc10da5a973534d9198:i221515:3:Health Car\xe5 \r\nEXPIRE 61806dc10da5a973534d9198:i221515:PIT:3 1800 \r\n
noahlz commented 3 years ago

Also here is an example stack trace:

Caused by: java.lang.Exception: ERR syntax error
  at com.redis.Reply$$anonfun$errReply$1.applyOrElse(RedisProtocol.scala:120)
  at com.redis.Reply$$anonfun$errReply$1.applyOrElse(RedisProtocol.scala:119)
  at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:38)
  at com.redis.Reply$$anonfun$queuedReplyLong$1.applyOrElse(RedisProtocol.scala:128)
  at com.redis.Reply$$anonfun$queuedReplyLong$1.applyOrElse(RedisProtocol.scala:128)
  at scala.PartialFunction$OrElse.apply(PartialFunction.scala:172)
  at com.redis.Reply$$anonfun$longReply$1.applyOrElse(RedisProtocol.scala:60)
  at com.redis.Reply$$anonfun$longReply$1.applyOrElse(RedisProtocol.scala:60)
  at scala.PartialFunction$OrElse.apply(PartialFunction.scala:172)
  at com.redis.Reply.receive(RedisProtocol.scala:140)
  at com.redis.Reply.receive$(RedisProtocol.scala:136)
  at com.redis.Redis.receive(RedisClient.scala:34)
  at com.redis.R.asLong(RedisProtocol.scala:251)
  at com.redis.R.asLong$(RedisProtocol.scala:251)
  at com.redis.Redis.asLong(RedisClient.scala:34)
  at com.redis.SortedSetOperations.$anonfun$zadd$2(SortedSetOperations.scala:11)
  at com.redis.RedisClient.$anonfun$batchedPipeline$4(RedisClient.scala:250)
noahlz commented 3 years ago

We can close this, @debasishg added the changes in a different PR