Commit graph

19 commits

Author SHA1 Message Date
Alejandro Rodríguez
1796936abc Handle large values on MergeRequestDiffCommit dates 2017-10-30 21:13:39 -03:00
Yorick Peterse
aac1de46c9
Use a specialized class for querying events
This changes various controllers to use the new EventCollection class
for retrieving events. This class uses a JOIN LATERAL query on
PostgreSQL to retrieve queries in a more efficient way, while falling
back to a simpler / less efficient query for MySQL.

The EventCollection class also includes a limit on the number of events
to display to prevent malicious users from cycling through all events,
as doing so could put a lot of pressure on the database.

JOIN LATERAL is only supported on PostgreSQL starting with version 9.3.0
and as such this optimisation is only used when using PostgreSQL 9.3 or
newer.
2017-08-10 17:45:49 +02:00
Rémy Coutable
ddccd24c13 Remove superfluous lib: true, type: redis, service: true, models: true, services: true, no_db: true, api: true
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Sean McGivern
d4a3474b9b Fix Gitlab::Database.bulk_insert for non-UTF-8 data 2017-06-26 17:21:40 +01:00
Grzegorz Bizon
0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Sean McGivern
9a73b634ab Add table for files in merge request diffs
This adds an ID-less table containing one row per file, per merge request
diff. It has a column for each attribute on Gitlab::Git::Diff that is serialised
currently, with the advantage that we can easily query the attributes of this
new table.

It does not migrate existing data, so we have fallback code when the legacy
st_diffs column is present instead. For a merge request diff to be valid, it
should have at most one of:

* Rows in this new table, with the correct merge_request_diff_id.
* A non-NULL st_diffs column.

It may have neither, if the diff is empty.
2017-06-16 18:30:01 +01:00
Robert Speicher
a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
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
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
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
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
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
Douwe Maan
13d6bab177 Tag lib specs 2015-12-09 11:55:42 +01: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