scala-redis-nb icon indicating copy to clipboard operation
scala-redis-nb copied to clipboard

RedisClient Factory Method Not Thread-Safe

Open JakeGreene opened this issue 9 years ago • 1 comments

The apply method within the RedisClient object is not thread-safe. It uses the thread-unsafe Iterator.next method to create a default name. This results in name collisions in Akka.

An example of the Iterator.next method not being thread-safe:

val i = Iterator from 0
val fs = Seq.fill(10000)(Future(i.next))
// This should print 10000 but will likely print something else (the last time I tried it was 9964)
Future.sequence(fs).foreach(values => println(values.toSet.size))

I've included a stack-trace showing the issue appearing in our production environment. redis-nb-name-bug-clean

JakeGreene avatar Oct 08 '14 15:10 JakeGreene

Thanks for pointing out .. have a look ..

debasishg avatar Nov 16 '14 15:11 debasishg