Kitura / Kitura-redis

Swift Redis library
Apache License 2.0
94 stars 25 forks source link

With Multi other threads give ... RedisDomain Code=2 \"Unexpected result received from Redis Status(\"QUEUED\")\" #63

Open icyield opened 6 years ago

icyield commented 6 years ago

I'm using the multi command. if let multi = redisDB?.multi() multi.lrange(dataflow.redisQueue, start: 0, end: len) multi.ltrim(dataflow.redisQueue, start: len+1, end: -1) //get len amount and remove atomically. multi.exec({ (response) in

Under high load I get errors from other threads (doing an rpush)

Error Domain=RedisDomain Code=2 \"Unexpected result received from Redis Status(\"QUEUED\")\"

It seems that the multi command is either not atomic or does not block access to the redis server to other commands while it is queuing commands.

Can I use the multi command while in a threaded environment?

icyield commented 6 years ago

As a fix I have added a separate redis instance. The multi cmd is done on the second instance and seems to have sorted the problem for me.

But in general seems like the multi cmd must be used with a Redis instance in a single thread.