Commit Graph

617 Commits

Author SHA1 Message Date
Eric Eastwood a5439897d2 Update issuable status icons
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/33926

Changed file icons already addressed in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15367
2017-12-13 00:11:57 -06:00
Zeger-Jan van de Weg 3ab026b7d6
Use memoization for commits on diffs
The Gitaly CommitService is being hammered by n + 1 calls, mostly when
finding commits. This leads to this gRPC being turned of on production:
https://gitlab.com/gitlab-org/gitaly/issues/514#note_48991378

Hunting down where it came from, most of them were due to
MergeRequest#show. To prove this, I set a script to request the
MergeRequest#show page 50 times. The GDK was being scraped by
Prometheus, where we have metrics on controller#action and their Gitaly
calls performed. On both occations I've restarted the full GDK so all
caches had to be rebuild.

Current master, 806a68a81f, needed 435 requests
After this commit, 154 requests
2017-12-12 16:28:26 +01:00
micael.bergeron 360b94ceba adding view and feature specs 2017-12-07 09:06:59 -05:00
micael.bergeron 16c8b91092 revert the `#all_pipelines` method to use the pluck
the `ci_pipelines.sha` column is not the same type than the
`merge_request_diff_commits.sha` column (varchar, bytea)
2017-12-07 09:02:42 -05:00
micael.bergeron cb6f51ec9b add support for the commit reference filter 2017-12-07 09:01:37 -05:00
micael.bergeron 716f9cbb41 tidying up the changes 2017-12-07 09:01:37 -05:00
micael.bergeron 3d8fbd12b8 add support for commit (in mr) to reference filter 2017-12-07 09:01:27 -05:00
Yorick Peterse 856447ccd3
Throttle the number of UPDATEs triggered by touch
This throttles the number of UPDATE queries that can be triggered by
calling "touch" on a Note, Issue, or MergeRequest. For Note objects we
also take care of updating the associated "noteable" relation in a
smarter way than Rails does by default.
2017-12-06 15:59:37 +01:00
Felipe Artur 5cf3ff27c8 Use actual head pipeline on merge request serializer 2017-12-05 12:54:10 -02:00
Felipe Artur f586dc0735 Check if head_pipeline is correct before merging 2017-12-05 12:54:10 -02:00
Felipe Artur 8f78ba554d Improve MergeRequest#head_pipeline 2017-12-05 12:54:10 -02:00
Jarka Kadlecova fe673b4927 Ensure pippeline corresponds with the sha of an MR 2017-12-05 12:54:10 -02:00
Lin Jen-Shin 4925ec5087 We could simply count the commits 2017-11-30 16:03:28 +08:00
Yorick Peterse 124fa93a8a Merge branch 'remove-mr-diff-serialised-columns' into 'master'
Remove serialised diff and commit columns

Closes #39533

See merge request gitlab-org/gitlab-ce!15582
2017-11-29 13:33:06 +00:00
Rémy Coutable becf29e3ab Merge branch '40530-merge-request-generates-wrong-diff-when-branch-and-tag-have-the-same-name' into 'master'
Resolve "Merge request generates wrong diff when branch and tag have the same name"

Closes #40530

See merge request gitlab-org/gitlab-ce!15591
2017-11-28 18:01:09 +00:00
Sean McGivern 3c6a4d6363 Ensure MRs always use branch refs for comparison
If a merge request was created with a branch name that also matched a tag name,
we'd generate a comparison to or from the tag respectively, rather than the
branch. Merging would still use the branch, of course.

To avoid this, ensure that when we get the branch heads, we prepend the
reference prefix for branches, which will ensure that we generate the correct
comparison.
2017-11-28 17:01:38 +00:00
Sean McGivern 4ebbfe5d3e Remove serialised diff and commit columns
The st_commits and st_diffs columns on merge_request_diffs historically held the
YAML-serialised data for a merge request diff, in a variety of formats.

Since 9.5, these have been migrated in the background to two new tables:
merge_request_diff_commits and merge_request_diff_files. That has the advantage
that we can actually query the data (for instance, to find out how many commits
we've stored), and that it can't be in a variety of formats, but must match the
new schema.

This is the final step of that journey, where we drop those columns and remove
all references to them. This is a breaking change to the importer, because we
can no longer import diffs created in the old format, and we cannot guarantee
the export will be in the new format unless it was generated after this commit.
2017-11-28 16:13:40 +00:00
George Andrinopoulos 7fb1bb01bd Create issue and merge request destroy services 2017-11-25 22:09:18 +02:00
Sean McGivern c4d844f08b Merge branch 'issue_40374' into 'master'
Fix WIP system note not being created

Closes #40374

See merge request gitlab-org/gitlab-ce!15528
2017-11-24 09:38:45 +00:00
Felipe Artur 5c2c471a83 Fix WIP system note not being created 2017-11-23 17:25:14 -02: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
George Andrinopoulos 3963f91ee3 Move update_project_counter_caches? out of issue and merge request 2017-11-11 21:06:28 +02:00
Sean McGivern ec73ecb0a8 Fix another timeout when searching for pipelines
When we consider 'all' pipelines for MRs, we now mean:

1. The last 10,000 commits (unordered).
2. From the last 100 MR versions (newest first).

This seems to fix the MRs that time out on GitLab.com.
2017-11-10 14:27:26 +00:00
Rémy Coutable bf13746fd8 Merge branch 'dm-notes-for-commit-id' into 'master'
Use Commit#notes and Note.for_commit_id when possible to make sure we use all indexes available to us

Closes #34509

See merge request gitlab-org/gitlab-ce!15253
2017-11-08 16:04:15 +00:00
Douwe Maan fec48c6e17 Use Commit#notes and Note.for_commit_id when possible to make sure we use all the indexes available to us 2017-11-08 12:22:11 +01:00
Jarka Kadlecova ad6e650262 Refactor issuables index actions 2017-11-07 14:34:12 +01:00
micael.bergeron bb0543ef47 ignore the column before the migration
reword the changelog
remove dead code in the specs
2017-11-06 09:03:11 -05: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
Jarka Kadlecova 064c8949bd CE port of code changed for epics 2017-11-02 07:14:35 +01:00
Yorick Peterse c14697a50b Merge branch '39054-activerecord-statementinvalid-pg-querycanceled-error-canceling-statement-due-to-statement-timeout' into 'master'
Resolve "ActiveRecord::StatementInvalid: PG::QueryCanceled: ERROR:  canceling statement due to statement timeout"

Closes #39054

See merge request gitlab-org/gitlab-ce!15063
2017-10-30 11:57:09 +00:00
Oswaldo Ferreira c4124fce48 Move locked check to a guard-clause 2017-10-30 11:21:23 +01:00
Oswaldo Ferreira a6c52c4e59 Make merge_jid handling less stateful in MergeService 2017-10-27 22:33:48 +02:00
Sean McGivern ba9b4c4de8 Avoid hitting statement timeout finding MR pipelines
For MRs with many thousands of commits, `SELECT DISTINCT(sha)` will be very
slow.

What we can't do to fix this:

1. Add an index. Postgres won't use it for DISTINCT without a lot of ceremony.
2. Do the `uniq` in Ruby. That can still be very slow with hundreds of
   thousands of commits.
3. Use a subquery. We haven't removed the `st_commits` column yet, but we will
   soon.

Until 3 is available to us, we can just do 2, but also add a limit clause. There
is no ordering, so this may return different results, but our goal with these
MRs is just to get them to load, so it's not a huge deal.
2017-10-27 14:20:55 +01:00
Oswaldo Ferreira b78954c13d Simplify check for running job on Redis 2017-10-13 10:17:41 +02:00
Oswaldo Ferreira 9ab0254085 Make "merge ongoing" check more consistent 2017-10-11 18:48:39 +02:00
Andrew Newdigate 47d19c2de1 Stop using `branch_names.include?` and use `branch_exists?` 2017-10-10 14:56:04 +00:00
Rémy Coutable f070265a6d
Introduce new hook data builders for Issue and MergeRequest
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 16:44:47 +02:00
Rémy Coutable 075d651604 Start adding Gitlab::HookData::IssuableBuilder
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 15:07:10 +02:00
Rémy Coutable 67d5ca9f92 Include the changes in issuable webhook payloads
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 15:07:10 +02:00
Douwe Maan 546b18b903 Merge branch 'tc-geo-read-only-idea' into 'master'
Create idea of read-only database

Closes #37534

See merge request gitlab-org/gitlab-ce!14688
2017-10-07 11:01:21 +00:00
Bob Van Landuyt 70716a1292 Allow creating merge requests across forks of a project 2017-10-07 11:46:23 +02:00
Toon Claes d13669716a Create idea of read-only database
In GitLab EE, a GitLab instance can be read-only (e.g. when it's a Geo
secondary node). But in GitLab CE it also might be useful to have the
"read-only" idea around. So port it back to GitLab CE.

Also having the principle of read-only in GitLab CE would hopefully
lead to less errors introduced, doing write operations when there
aren't allowed for read-only calls.

Closes gitlab-org/gitlab-ce#37534.
2017-10-06 22:37:40 +02:00
Rémy Coutable 67de21c15b Move `fetch_ref` from MergeRequestDiff#ensure_commit_shas to MergeRequest
MergeRequest#create_merge_request_diff and MergeRequest#reload_diff are
the only places where we generate a new MR diff so that's where we
should fetch the ref.

This also ensures that the ref is not fetched when we call
merge_request.merge_request_diffs.create in
Github::Import#fetch_pull_requests.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-05 10:48:25 +02:00
Sean McGivern b1050bfe39 Merge branch 'merge-request-notes-performance' into 'master'
Use a UNION ALL for getting merge request notes

Closes #38508

See merge request gitlab-org/gitlab-ce!14620
2017-10-04 12:03:32 +00:00
Douwe Maan 2ee93c486c Merge branch '36876-mr-show-json-controller-perf-improvements' into 'master'
Reduce method calls while evaluating Projects::MergeRequestsController#show.json

See merge request gitlab-org/gitlab-ce!14285
2017-10-04 07:33:05 +00:00
Oswaldo Ferreira 1f54c9216f Reduce method calls while evaluating Projects::MergeRequestsController#show.json 2017-10-04 00:09:48 -03:00
Yorick Peterse c16b99a49c
Use a UNION ALL for getting merge request notes
In this particular case the use of UNION ALL leads to a better query
plan compared to using 1 big query that uses an OR statement to combine
different data sources.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/38508 for more
information.
2017-10-02 15:31:59 +02:00
Eric Eastwood 439e3f0735 Port semi-linear merge strategy to CE (mostly FE) 2017-09-29 14:13:35 -05:00
Yorick Peterse 57b96eb6db
Fix refreshing of issues/MR count caches
This ensures the open issues/MR count caches are refreshed properly when
creating new issues or MRs. This MR also includes a change to the cache
keys to ensure all caches are rebuilt on the fly.

This particular problem was not caught in the test suite due to a null
cache being used, resulting in all calls that would use a cache using
the underlying data directly. In production the code would fail because
a newly saved record returns an empty hash in #changes meaning checks
such as `state_changed? || confidential_changed?` would return false for
new rows, thus never updating the counters.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/38061
2017-09-19 17:16:45 +02:00
Andrew Newdigate 64d7ec0a9e Detect n+1 issues involving Gitaly 2017-09-19 10:55:37 +00:00