Supress sqlite fork warnings for rails 7.1 & 7.2 by p-schlickmann · Pull Request #611 · rails/solid_queue

@p-schlickmann

When sqlite3 > 2.1.0 and rails < 8.0.0 we have the following warning when using Solid Queue:

.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sqlite3-2.5.0-x86_64-linux-gnu/lib/sqlite3/fork_safety.rb:43: warning: Writable sqlite database connection(s) were inherited from a forked process. This is unsafe and the connectio
ns are being closed to prevent possible data corruption. Please close writable sqlite database connections before forking.

This is polluting our CI logs and triggering warnings for people using Solid Queue with Rails 7.1 and 7.2 - although the behaviour is safe: #324 (comment)

Also mentioned in: #506

@p-schlickmann

Actually, the warning is still showing up in the CI - wait a sec.

@p-schlickmann

@rosa

Hey @p-schlickmann, thanks a lot for this! I think I'd keep only the call for tests only, in test/test_helpers/processes_test_helper.rb, but not the one in the supervisor code. I'd leave that to Solid Queue users on Rails < 8 to decide whether they want to call that or not (and maybe they can do it in the on_start hook, because I think the warnings happen on fork, and on_start runs before forking in the Supervisor 🤔 ).

@p-schlickmann

Yes, @rosa, that approach should work!

But in addition to cleaning up the CI logs, the goal of this PR is to reassure Solid Queue users on Rails 7.1 and 7.2 that the forking warning is harmless and can be safely ignored.

Maybe it makes sense to open a PR against the Rails repo to suppress this warning upstream in Rails 7 itself? Like they did for Rails 8?

@rosa

Maybe, yes, I'd prefer that if the core team allows it.

@p-schlickmann

@p-schlickmann

@rosa, unfortunately we can’t apply the same fix in Rails 7 because SQLite3::ForkSafety.suppress_warnings! was included in sqlite3 >= 2.1, while Rails 7 minimum supported version is 1.4.

I don't think a warning is gonna make the rails team bump such a major version like that.

In any case, I’ve pushed a commit to suppress those warnings in our CI, so our test output is now completely clean 🎉

rosa

rosa approved these changes Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!