- 14 Mar, 2017 1 commit
-
-
Yorick Peterse authored
This adds support for balancing queries amongst multiple database hosts. Web requests will stick to using the primary for a little while after a write took place, removing the need for synchronous replication. Load balancing is disabled for Sidekiq since using this could lead to race conditions, and Sidekiq mostly performs writes anyway. == Balancing Balancing is done using a simple round-robin algorithm. The first time a connection is needed the first host is used, then the second, third, etc. This logic resets to the first host once reaching the end of the hosts list. The code added in this commit _only_ load balances queries sent from models. The code does _not_ touch ActiveRecord::Base.connection. This means that direct use of this method will result in the queries being sent to the primary. == Configuration Configuration is done by adding a YAML section to config/database.yml. For example: production: load_balancing: hosts: - 10.0.0.1 - 10.0.0.2 All hosts will use the same authentication credentials. == Sticking When a write is performed the query is sent to the primary. Any queries executed after this point are also sent to the primary. At the end of a request some session details are stored for the current user, these details are used to stick to the primary for as long as necessary (or until the data expires). This prevents the user from running into cases where they write data to the primary, read from the secondary, and the data isn't available yet (e.g. leading to an HTTP 404 error). == Overhead The load balancing code has minimal overhead. Instead of parsing raw SQL queries it hooks into Rails specific methods to determine what host to use for a query. == Transactions Transactions are always executed on the primary, even if they don't perform any writes. Once a transaction completes a session will stick to the primary. This is based on transactions almost always being used for writes (there's little benefit to using a transaction for only reads). == Prepared Statements Prepared statements don't work well when queries are being distributed amongst hosts. As a result GitLab will automatically disable prepared statements when load balancing is enabled. Disabling prepared statements has no impact on response timings, and may even reduce the memory usage of PostgreSQL. == Failovers The load balancing code is capable of dealing with database failovers. In the event of a secondary being unavailable the load balancer will mark it as offline and use the next available secondary. If no secondaries are available the primary is used instead. Secondaries that are marked as offline are checked again automatically, preventing a host from being marked as offline forever. In the event of a connection error when writing to the primary the code will suspend the caller, then retry the operation up to 3 times. Every retry the sleep time will increase exponentially. All of this means that in the event of a DB restart or failover some requests may take a bit longer to complete; instead of the application immediately returning an error.
-
- 10 Mar, 2017 20 commits
-
-
Douwe Maan authored
Execute inflections initializer earlier Closes #1892 See merge request !1408
-
Filipa Lacerda authored
Add frequently used emojis back to awards menu -- EE merge edition See merge request !1403
-
Clement Ho authored
Only replace non-approval mr-widget-footer on getMergeStatus. Closes #1866 See merge request !1393
-
Douglas Barbosa Alexandre authored
-
Douglas Barbosa Alexandre authored
Makes sure that we set the acronyms before the metrics initializer runs. Otherwise, `camelize` will not consider these acronyms.
-
Rémy Coutable authored
CE upstream: Thursday Closes gitlab-ce#29192, #1381, and gitlab-com/infrastructure#1139 See merge request !1398
-
Nick Thomas authored
-
Nick Thomas authored
-
Lin Jen-Shin authored
which isn't properly cleaning up whenever something is thrown, not raised. See: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1402#note_25128108
-
Sean McGivern authored
Fix 500 when selecting a mirror user Closes gitlab-ce#29316 See merge request !1404
-
Achilleas Pipinellis authored
Add detailed explanation of merge options Closes #257 See merge request !1350
-
Douglas Barbosa Alexandre authored
-
Nick Thomas authored
-
Nick Thomas authored
-
Sean McGivern authored
When selecting a mirror user, we do a permissions check, which means that `@users` is an array, not an ActiveRecord relation. We also can't use `Array#delete`, because it uses `Object#equal?`, while we need to be able to take advantage of ActiveRecord objects overriding `#eql?` and `#hash?` (as `Array#uniq` uses a hash internally).
-
Eric Eastwood authored
Thanks @filipa for the shout` Conflicts: spec/javascripts/awards_handler_spec.js
-
Rémy Coutable authored
Add update doc for CE 9.0 to EE 9.0 See merge request !1394
-
Bryce Johnson authored
-
Rémy Coutable authored
Update storage settings to allow extra values per shard See merge request !1362
-
DJ Mountney authored
-
- 09 Mar, 2017 19 commits
-
-
Douglas Barbosa Alexandre authored
-
Douwe Maan authored
Add Upload count to usage data See merge request !1401
-
Nick Thomas authored
-
Nick Thomas authored
-
Nick Thomas authored
-
Nick Thomas authored
Fix Projects::UpdateService#repository_storage spec to take account of schema changes in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9597
-
Nick Thomas authored
Fix the #change_repository_storage tests to take account of schema changes in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9597
-
Robert Speicher authored
-
Nick Thomas authored
-
Nick Thomas authored
-
Nick Thomas authored
-
Sean McGivern authored
Improve storage validation after configuration structure update See merge request !9811
-
Kamil Trzciński authored
Verbosify blocked pipeline status description Closes #29134 See merge request !9800
-
Dmitriy Zaporozhets authored
Change activity view wording See merge request !9777
-
Rémy Coutable authored
CE upstream Closes gitaly#109 and gitlab-ce#28515 See merge request !1371
-
Alfredo Sumaran authored
Move u2f javascript library to webpack config See merge request !9755
-
Rémy Coutable authored
Fix wrong message on starred projects filtering Closes #28402 See merge request !9488
-
George Andrinopoulos authored
-
Robert Speicher authored
Update the gitignore and gitlab-ci templates for 9.0 See merge request !9824
-