Ractor safety #1895
HoneyryderChuck
started this conversation in
General
Ractor safety
#1895
Replies: 1 comment
-
With current limitations of Ractor, I don't think there is any chance of Sequel being able to use it. If you want thread-level parallelism when using Sequel, I recommend using JRuby. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
👋 I am using sequel for this tool I'm working on, where there's a pool of workers, each using the default connection pool to pick a connection tu use. Recently, I've been toying with the idea of adding support for a pool of ractors. In order to make it work though, sequel would need to at least be ractor-safe, which is not at the moment.
The first issue is that database instances, even if frozen, aren't shareable:
This can be overcome by initializing the database instance within the ractor:
But then all other sorts of issues happen, the first of which is, using ADAPTER_MAP when connecting fails, as it's a mutable constant.
I've made a local patch to ditch its usage and rely on
Sequel::Database.subclasses.find
and.adapter_scheme
. I believe the scheme cache ofADAPTER_MAP
optimizes a cold path (connecting happens usually once per database URL, and there aren't usually many of them). There's of course the open question of what to do with the double declaration of the postgres adapter overriding the scheme, I guess this is for backwards-compatibility?And this is just the beginning:
Sequel.synchronize
is used liberally in a few places, and is definitely not ractor-friendly; moreover,sequel
caches a lot of method-to-proc coercers, which aren't themselves ractor-shareable I've created an issue in ruby about whether these procs should be considered exceptions.This is the summary of early discovery. I don't know how much Jeremy is interested in making
sequel
work under ractors, and while I believe that it's going to take a lot of effort making the whole ofsequel
ractor-friendly, I wonder how much one has to do in order to make the vanilla "no-plugin" XP usable.Is this something worth undertaking, or a rabbit-hole someone may have gone through in the past already?
Beta Was this translation helpful? Give feedback.
All reactions