-
Notifications
You must be signed in to change notification settings - Fork 211
Use a single connection pool across the whole application #843
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
Conversation
How certain are we that the pool is fork-safe? (Given that we initialise it and pass it off to |
Good point. I'd be tempted to just remove the forking code: we run docs.rs on production with systemd, and tbh everyone should just do that. |
+1, I think self-backgrounding is an antipattern that can be dropped. Last I asked about it @jyn514 said it was used in production still, so might need a reconfiguration there to stop using it. |
Opened #844 to remove forking. |
Technically all IO is unsafe unless it's been explicitly whitelisted:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly minor nits, overall this looks great :)
I was more thinking that if the pool spawns a background thread to deal with closing old connections that thread won't make it across the |
Replied to or addressed all review comments. |
Marking as P-high since it blocks #822. |
Rebased on top of the latest master and fixed the last concern in the last commit. r? @jyn514 |
This PR changes how database connections are handled in the docs.rs application:
web::InjectExtensions
to its own file andweb::pool::Pool
todb::pool::Pool
.Config
instead of being loaded from the environment each time a connection is created.Pool
, which is created in thecratesfyi
CLI and passed around. One result of this is that the frontend and the builds will use the same pool, instead of having the builds create standalone connections when needed.db::connect_db()
is removed, forcing every connection to go through the database pool.This PR is part of my refactorings to make buildtests feasible, and is best reviewed commit by commit. Unfortunately the last commit is quite big, but there was no way to split it.