[openstreetmap/openstreetmap-website] WIP: Use database replicas for read requests (#3201)
Andy Allan
notifications at github.com
Wed May 19 16:29:40 UTC 2021
Fixes #2634
The connection switching is managed using the standard Resolver, which chooses the connection based on the HTTP verb. In the small number of cases where we update the database during GET requests, we override the default choice of connections.
Additionally, after any write in a particular user session, the resolver will continue to use the same (write) connection for two seconds for subsequent reads. This gives time for the changes to be replicated before switching back.
Unfortunately [there's a bug in rails when running migrations](https://github.com/rails/rails/issues/41855) so we can't merge this yet, but I thought I would push this now for review and discussion anyway. It contains a lot fewer connection overrides than when I last looked at this, since there's been some refactoring in the meantime as we move more things to standard new/create/update/etc.
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/3201
-- Commit Summary --
* Use database replicas for read requests
-- File Changes --
M app/controllers/api_controller.rb (5)
M app/controllers/application_controller.rb (6)
M app/controllers/confirmations_controller.rb (4)
M app/controllers/messages_controller.rb (10)
M app/controllers/user_blocks_controller.rb (6)
M app/controllers/users_controller.rb (4)
M app/models/application_record.rb (2)
M app/models/client_application.rb (4)
M app/models/oauth_nonce.rb (5)
M app/models/request_token.rb (20)
M app/views/site/id.html.erb (13)
M config/application.rb (4)
M config/docker.database.yml (32)
M config/environments/production.rb (2)
M config/example.database.yml (48)
M config/github.database.yml (10)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/3201.patch
https://github.com/openstreetmap/openstreetmap-website/pull/3201.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3201
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20210519/e6893d5d/attachment.htm>
More information about the rails-dev
mailing list