Commit Graph

2270 Commits

Author SHA1 Message Date
Douwe Maan ad70fb7bdc Merge branch 'use-merge-requests-diff-id-column' into 'master'
Use foreign key to get latest MR diff

Closes #37631

See merge request gitlab-org/gitlab-ce!15126
2017-11-23 15:01:30 +00:00
Markus Koller 257fd57134 Allow password authentication to be disabled entirely 2017-11-23 13:16:14 +00:00
Sean McGivern 991bf24ec8 Use latest_merge_request_diff association
Compared to the merge_request_diff association:

1. It's simpler to query. The query uses a foreign key to the
   merge_request_diffs table, so no ordering is necessary.
2. It's faster for preloading. The merge_request_diff association has to load
   every diff for the MRs in the set, then discard all but the most recent for
   each. This association means that Rails can just query for N diffs from N
   MRs.
3. It's more complicated to update. This is a bidirectional foreign key, so we
   need to update two tables when adding a diff record. This also means we need
   to handle this as a special case when importing a GitLab project.

There is some juggling with this association in the merge request model:

* `MergeRequest#latest_merge_request_diff` is _always_ the latest diff.
* `MergeRequest#merge_request_diff` reuses
  `MergeRequest#latest_merge_request_diff` unless:
    * Arguments are passed. These are typically to force-reload the association.
    * It doesn't exist. That means we might be trying to implicitly create a
      diff. This only seems to happen in specs.
    * The association is already loaded. This is important for the reasons
      explained in the comment, which I'll reiterate here: if we a) load a
      non-latest diff, then b) get its `merge_request`, then c) get that MR's
      `merge_request_diff`, we should get the diff we loaded in c), even though
      that's not the latest diff.

Basically, `MergeRequest#merge_request_diff` is the latest diff in most cases,
but not quite all.
2017-11-23 12:14:56 +00:00
Shinya Maeda fd83bb0338 Remove cluster_id from 20171013104327_migrate_gcp_clusters_to_new_clusters_architectures 2017-11-23 20:42:20 +09:00
Shinya Maeda 98bb78a4bd Add environment_scope to cluster table 2017-11-22 16:09:10 +09:00
Yorick Peterse aafe5c123e
Update composite pipelines index to include "id"
This updates the composite index on ci_pipelines (project_id, ref,
status) to also include the "id" column at the end. Adding this column
to the index drastically improves the performance of queries used for
getting the latest pipeline for a particular branch. For example, on
project dashboards we'll run a query like the following:

    SELECT ci_pipelines.*
    FROM ci_pipelines
    WHERE ci_pipelines.project_id = 13083
    AND ci_pipelines.ref = 'master'
    AND ci_pipelines.status = 'success'
    ORDER BY ci_pipelines.id DESC
    LIMIT 1;

    Limit  (cost=0.43..58.88 rows=1 width=224) (actual time=26.956..26.956 rows=1 loops=1)
      Buffers: shared hit=6544 dirtied=16
      ->  Index Scan Backward using ci_pipelines_pkey on ci_pipelines  (cost=0.43..830922.89 rows=14216 width=224) (actual time=26.954..26.954 rows=1 loops=1)
            Filter: ((project_id = 13083) AND ((ref)::text = 'master'::text) AND ((status)::text = 'success'::text))
            Rows Removed by Filter: 6476
            Buffers: shared hit=6544 dirtied=16
    Planning time: 1.484 ms
    Execution time: 27.000 ms

Because of the lack of "id" in the index we end up scanning over the
primary key index, then applying a filter to filter out any remaining
rows. The more pipelines a GitLab instance has the slower this will get.

By adding "id" to the mentioned composite index we can change the above
plan into the following:

    Limit  (cost=0.56..2.01 rows=1 width=224) (actual time=0.034..0.034 rows=1 loops=1)
      Buffers: shared hit=5
      ->  Index Scan Backward using yorick_test on ci_pipelines  (cost=0.56..16326.37 rows=11243 width=224) (actual time=0.033..0.033 rows=1 loops=1)
            Index Cond: ((project_id = 13083) AND ((ref)::text = 'master'::text) AND ((status)::text = 'success'::text))
            Buffers: shared hit=5
    Planning time: 0.695 ms
    Execution time: 0.061 ms

This in turn leads to a best-case improvement of roughly 25
milliseconds, give or take a millisecond or two.
2017-11-21 17:48:52 +01:00
Yorick Peterse 17132b99aa
Fix merge_requests.source_project_id migration
We need to make sure merge_requests.source_project_id allows NULL values
_before_ updating rows as otherwise this will lead to a NOT NULL
constraint failing.
2017-11-20 18:00:47 +01:00
Yorick Peterse 936e9e8950
Clean up schema of the "merge_requests" table
This adds various foreign keys and indexes to the "merge_requests" table
as outlined in https://gitlab.com/gitlab-org/gitlab-ce/issues/31825.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/31825
2017-11-20 12:45:33 +01:00
Rémy Coutable 4f09d099e9 Merge branch '18040-rubocop-line-break-after-guard-clause' into 'master'
Adds Rubocop rule for line break after guard clause

Closes #18040

See merge request gitlab-org/gitlab-ce!15188
2017-11-20 09:22:14 +00:00
Rémy Coutable 33b4da0a3c Merge branch 'rs-cycle-analytics-seed' into 'master'
Update CycleAnalytics seed to account for multiple issue assignees

Closes #40245

See merge request gitlab-org/gitlab-ce!15435
2017-11-20 08:35:02 +00:00
Robert Speicher d63b39c37d Merge branch 'restrict-update-column-in-batches-for-large-tables' into 'master'
Restrict update column in batches for large tables

See merge request gitlab-org/gitlab-ce!15458
2017-11-17 18:58:22 +00:00
Sean McGivern d8be981466 Prevent update_column_in_batches on large tables
add_column_with_default is implemented in terms of update_column_in_batches, but
update_column_in_batches can be used independently. Neither of these should be
used on the specified large tables, because they will cause issues on large
instances like GitLab.com.

This also ignores the cop for all existing migrations, renaming
AddColumnWithDefaultToLargeTable where appropriate.
2017-11-17 16:56:50 +00:00
Douwe Maan 371180a47d Merge branch 'mk-add-user-rate-limits' into 'master'
Add request rate limits

Closes #30053

See merge request gitlab-org/gitlab-ce!14708
2017-11-17 16:11:22 +00:00
Douwe Maan 5c0ba938aa Merge branch 'bvl-delete-empty-fork-networks' into 'master'
Delete empty fork networks

See merge request gitlab-org/gitlab-ce!15373
2017-11-17 14:21:36 +00:00
Bob Van Landuyt 8f84369ae1 Delete orphaned fork networks in a migration 2017-11-17 12:58:15 +01:00
Stan Hu 5cecff893d Convert migration to populate latest merge request ID into a background migration
This is to smear updates over a few hours to avoid causing excessive
replication lag as seen in https://gitlab.com/gitlab-com/infrastructure/issues/3235.
2017-11-17 10:23:48 +00:00
Michael Kozono 732b122644 Add throttle application settings 2017-11-17 09:58:18 +01:00
Robert Speicher 7897d04fcb Update CycleAnalytics seed to account for multiple issue assignees 2017-11-16 15:26:12 -06:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Yorick Peterse d825c9cb5d
Clean up schema of the "issues" table
This adds various foreign key constraints, indexes, missing NOT NULL
constraints, and changes some column types from timestamp to
timestamptz.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/31811
2017-11-09 18:00:30 +01:00
Kamil Trzcinski fa3af6de66 Fix db/schema.rb 2017-11-07 19:46:45 +01:00
Kamil Trzcinski e957ea4ae1 Merge branch '38464-k8s-apps' of https://gitlab.com/gitlab-org/gitlab-ce into add-ingress-to-cluster-applications 2017-11-07 17:54:03 +01:00
Shinya Maeda c3b79df724 Fix schema version 2017-11-08 01:50:14 +09:00
Kamil Trzcinski 46bc6b5d8f Merge branch '38464-k8s-apps' into add-ingress-to-cluster-applications 2017-11-07 14:54:45 +01:00
Shinya Maeda bbdb0cf051 Merge branch 'master' into 38464-k8s-apps 2017-11-07 21:23:54 +09:00
Rémy Coutable 31e3ef93e5 Merge branch 'feature/custom-attributes-on-projects-and-groups' into 'master'
Support custom attributes on groups and projects

See merge request gitlab-org/gitlab-ce!14593
2017-11-07 10:59:38 +00:00
Eric Eastwood fd9be1dd1f Merge branch '38464-k8s-apps' into add-ingress-to-cluster-applications 2017-11-06 17:07:17 -06:00
Eric Eastwood a46d32412e Merge branch 'master' into 38464-k8s-apps
Conflicts:
	db/schema.rb
2017-11-06 17:03:31 -06:00
Grzegorz Bizon c71cf908cd Merge branch 'refactor-clusters' into 'master'
Refactor Clusters to be consisted from GcpProvider and KubernetesPlatform

See merge request gitlab-org/gitlab-ce!14879
2017-11-06 21:21:27 +00:00
Kamil Trzcinski 46cac8510b Fix db/schema.rb 2017-11-06 20:46:05 +01:00
Eric Eastwood 39dd1c66dd Merge branch '38464-k8s-apps' into add-ingress-to-cluster-applications 2017-11-06 13:39:54 -06:00
Sean McGivern 045795d0d9 Merge branch 'remove-ensure-ref-fetched-from-controllers' into 'master'
removed the #ensure_ref_fetched from all controllers

Closes #36061

See merge request gitlab-org/gitlab-ce!15129
2017-11-06 17:10:18 +00:00
Alessio Caiazza b893a85880 db/schema.rb cleanup 2017-11-06 16:04:58 +01:00
Markus Koller 1f773a8ef5
Support custom attributes on groups 2017-11-06 10:51:50 +01:00
Markus Koller 6902848a9c
Support custom attributes on projects 2017-11-06 10:51:46 +01:00
Kamil Trzcinski d8223468ae Add ingress application 2017-11-06 10:41:27 +01:00
Alessio Caiazza 317c3cdd33 Merge branch 'refactor-clusters' into 38464-k8s-apps 2017-11-06 10:25:43 +01:00
Kamil Trzcinski 4274418733 Merge remote-tracking branch 'origin/refactor-clusters' into 36629-35958-add-cluster-application-section 2017-11-06 10:10:06 +01:00
Shinya Maeda eba27fe022 Fix statis analysys 2017-11-05 19:49:34 +09:00
Shinya Maeda b737282ac7 Merge branch 'master' into refactor-clusters 2017-11-05 19:36:12 +09:00
Valery Sizov 3959460ce0 Put a condition to old migration that adds fast_forward column to MRs 2017-11-04 14:20:27 +02:00
Shinya Maeda 8fb7e87806 Move migration file to post-migration. Use EachBatch. batch_size 1 2017-11-04 03:22:04 +09:00
Shinya Maeda 8d8a860fbb Fix MigrateGcpClustersToNewClustersArchitectures. Improve spec 2017-11-03 21:16:34 +09:00
micael.bergeron 84b9343230 make the migration reversible 2017-11-03 08:13:11 -04:00
micael.bergeron 5c367a2a36 add changelog and move migration to post_migrate 2017-11-03 08:13:11 -04:00
micael.bergeron cd88fa8f80 removed the #ensure_ref_fetched from all controllers
also, I refactored the MergeRequest#fetch_ref method to express
the side-effect that this method has.

  MergeRequest#fetch_ref -> MergeRequest#fetch_ref!
  Repository#fetch_source_branch -> Repository#fetch_source_branch!
2017-11-03 08:13:11 -04:00
Alessio Caiazza 1ca9aaf860 Merge branch 'refactor-clusters' into 38464-k8s-apps 2017-11-03 11:02:59 +01:00
Kamil Trzcinski 1bbeafc3e1 Merge remote-tracking branch 'origin/master' into 38464-k8s-apps 2017-11-03 09:46:53 +01:00
Shinya Maeda 600d5f4fba Fix tests. Remove NOT NULL constraint from cluster.user. 2017-11-03 17:22:49 +09:00
Shinya Maeda 6ebe6792de Merge branch 'master' into refactor-clusters 2017-11-03 16:41:50 +09:00