sparklemotion / sparklemotion/sqlite3-ruby

Ractor support

Open
#299 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Ruby
Stars
845
Forks
220
Avg merge
2d 17h
Merged PRs (30d)
3

Description

Hello maintainers,

Is there any interest or planned change to add support to this gem for use within a Ruby 3 Ractor?

Currently, constructing a database instance is failing with the error message introduced into this Ruby commit. I have collected this stacktrace:

~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:89:in `open_v2': ractor unsafe method called from not main ractor (Ractor::UnsafeError)
        from ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:89:in `initialize'
        ...

It can be reproduced by:

sqlite_ractor = Ractor.new do
    db = SQLite3::Database.open "xyz.db"
end
puts sqlite_ractor.take

The Ruby commit message justifies the error because:

C extensions can violate the ractor-safety

However, this gem doesn't appear to store references to Ruby objects that might be accessed across Ractors / invalidly shared, so perhaps its C extensions can be marked as Ractor-safe?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/sqlite3/database.rb:89 and run the Ractor reproduction in the issue under Ruby 3. Trace the C-extension path involved in opening the database and determine what Ractor support requires. Done means the example can construct and use the database from a non-main Ractor without Ractor::UnsafeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, sqlite
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.