Skip to content

Supress sqlite fork warnings for rails 7.1 & 7.2 #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025

Conversation

p-schlickmann
Copy link
Contributor

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
Copy link
Contributor Author

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

@p-schlickmann p-schlickmann force-pushed the supress-sqlite-fork-warnings branch from 90cf406 to c5f43a0 Compare July 23, 2025 14:45
@p-schlickmann
Copy link
Contributor Author

Done! No more warnings in the CI as well: https://github.com/rails/solid_queue/actions/runs/16473942583/job/46570298080?pr=611

@rosa
Copy link
Member

rosa commented Jul 24, 2025

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
Copy link
Contributor Author

p-schlickmann commented Jul 24, 2025

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
Copy link
Member

rosa commented Jul 24, 2025

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

@p-schlickmann p-schlickmann force-pushed the supress-sqlite-fork-warnings branch from c5f43a0 to 9853aca Compare July 24, 2025 22:16
@p-schlickmann
Copy link
Contributor Author

@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 🎉

Copy link
Member

@rosa rosa left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@rosa rosa merged commit e5eb9fc into rails:main Jul 28, 2025
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants