RedisClient::RESP3::DUMP_TYPES being mutable makes it non ractor compatible
Closed this issue ยท 4 comments
Hi!
I'm trying to use the redis client within a simple ractor to maintain some data in redis, something like this:
ractor = Ractor.new do
redis = Redis.new
loop do
message = Ractor.receive
processed_message = perform_computations(message)
redis.set('my_key', processed_message)
end
end
# later
ractor.send(data)
This however fails with #<Thread:0x000000017cf100b8 run> terminated with exception (report_on_exception is true): can not access non-shareable objects in constant RedisClient::RESP3::DUMP_TYPES by non-main ractor. (Ractor::IsolationError)
This was introduced in 9fb715f
Yeah, redis-client
isn't tested for compatibility with Ractors. I don't mind trying to make it compatible, but I suspect this isn't the only issue.
I encourage you to fork and try to make the necessary modifications (even as hacks) to make it work, see if you encover anything else. Would be good to at least know how many issues may be there.
Yeah, would need some tests. I don't mind making changes to be Ractor compatible, but without regressions tests I'd quickly break it.
As for losing the cache, it's not too bad as aside from perhaps Strings, it's rare to subclass these.