Commit Graph

21 Commits

Author SHA1 Message Date
Tiago Botelho c41df67676 removes redundant code from database.rb 2017-04-11 20:20:19 +01:00
Yorick Peterse 9a20ff1c99
Added Gitlab::Database.config
This returns the ActiveRecord configuration for the current environment.

While CE doesn't use this very often, EE will use it in a few places for
the database load balancing code. I'm adding this to CE so we don't end
up with merge conflicts in this file.
2017-03-17 17:08:10 +01:00
Tiago Botelho 53760bb836 removes redundant code from gitlab database file 2017-03-02 20:29:32 +00:00
Yorick Peterse cf521c9576
Allow setting of a custom connection pool host
This allows you to set a custom host when calling
Gitlab::Database.create_connection_pool. This is necessary for load
balancing as in this case we want to inherit all settings except for the
hostname.
2017-02-22 15:47:53 +01:00
Yorick Peterse f802ad370e Merge branch 'create-connection-pool' into 'master'
Introduce Gitlab::Database.with_connection_pool

See merge request !9192
2017-02-14 12:05:07 +00:00
Lin Jen-Shin 03f1abfcc3 Only ensure against yield so that pool should be available
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9192#note_23293693
2017-02-14 13:48:13 +08:00
Lin Jen-Shin 136dc79433 Have some simple way to create connection pool 2017-02-14 00:35:25 +08:00
Yorick Peterse 581cfbae24
Don't connect in Gitlab::Database.adapter_name
We don't need to connect when requesting the name of the database
adapter. This in turn should prevent us from requesting/leaking
connections just by asking whether we're using PostgreSQL or MySQL.
2017-02-13 17:13:02 +01:00
Douwe Maan c8b63a28af Improve performance of finding last deployed environment 2017-02-06 16:12:24 -06:00
Yorick Peterse 92b2c74ce1
Refresh project authorizations using a Redis lease
When I proposed using serializable transactions I was hoping we would be
able to refresh data of individual users concurrently. Unfortunately
upon closer inspection it was revealed this was not the case. This could
result in a lot of queries failing due to serialization errors,
overloading the database in the process (given enough workers trying to
update the target table).

To work around this we're now using a Redis lease that is cancelled upon
completion. This ensures we can update the data of different users
concurrently without overloading the database.

The code will try to obtain the lease until it succeeds, waiting at
least 1 second between retries. This is necessary as we may otherwise
end up _not_ updating the data which is not an option.
2016-11-25 13:35:01 +01:00
Ahmad Sherif fd05e26618 Precalculate user's authorized projects in database
Closes #23150
2016-11-18 20:25:45 +02:00
Grzegorz Bizon e15b63b34e Fix methods visibility in gitlab database module 2016-07-19 15:12:14 +02:00
Stan Hu 7c9eba8919 Fix RangeError exceptions when referring to issues or merge requests outside of max database values
When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we
get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method
that will throw out out-of-bounds values.

Closes #18777
2016-06-18 13:07:38 -07:00
Z.J. van de Weg b2df118561 Random selection now also works for MySQL 2016-06-15 12:10:41 +02:00
Rémy Coutable 499bb9f305 Improve Issuable.order_labels_priority
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-06 11:59:49 -05:00
Connor Shea 377583a361
Enable Rubocop Casecmp Performance Cop.
Also fixes the errors caused by enabling the cop. casecmp is more performant than `.downcase` and `==`.
2016-05-10 18:23:25 -06:00
Robert Speicher 447568d15f Fix undefined method `postgresql?` during migration 2016-02-15 14:13:47 -05:00
Robert Speicher 4105f292e1 Display database type and version in Administration dashboard
Closes #12900
2016-02-02 17:59:09 -05:00
Kamil Trzcinski d5c91bb9a6 Migrate CI WebHooks and Emails to new tables 2015-12-10 16:04:08 +01:00
Douwe Maan 05cb65dc1f Fix Gitlab::Database#mysql? 2015-10-22 10:18:44 +02:00
Yorick Peterse 85c6a3743a Added methods for detecting MySQL/PostgreSQL
These two methods remove the need for manually going into
ActiveRecord::Base.connection all over the place.
2015-10-07 23:32:14 +02:00