Skip to content
Snippets Groups Projects
  1. Feb 09, 2018
  2. Feb 08, 2018
    • Gregory Stark's avatar
      Add indexes and change SQL for expired artifacts to deal with artifacts migration efficiently · 271e7a32
      Gregory Stark authored
      Artifacts are in the middle of being migrated from ci_builds to
      ci_job_artifacts. The expiration date is currently visible in both of
      these tables and the test for whether an expired artifact is present
      for a job is complex as it requires checking both the of the tables.
      
      Add two new indexes, one on ci_builds.artifacts_expire_at and one on
      ci_job_artifacts.expire_at to enable finding expired artifacts
      efficiently.
      
      And until the migration is finished, replace the SQL for finding
      expired and non-expired artifacts with a hand-crafted UNION ALL based
      query instead of using OR. This overcomes a database optimizer
      limitation that prevents it from using these indexes.
      
      When the migration is finished the next version should remove this
      query and replace it with a much simpler query on just
      ci_job_artifacts. See
      https://gitlab.com/gitlab-org/gitlab-ce/issues/42561 for followup.
      271e7a32
  3. Feb 07, 2018
  4. Feb 06, 2018
  5. Jan 31, 2018
  6. Jan 26, 2018
  7. Jan 14, 2018
    • Stan Hu's avatar
      Ensure CI pipelines and builds have the correction project associations · 8ddb00ad
      Stan Hu authored
      This should reduce the number of SQL queries and lookups needed to look up a
      project of a build and pipeline and vice versa.
      
      Before:
      
      ```
      [1] pry(main)> Ci::Build.reflect_on_association(:project).has_inverse?
      => false
      [2] pry(main)> Project.reflect_on_association(:builds).has_inverse?
      => false
      [3] pry(main)> Ci::Pipeline.reflect_on_association(:project).has_inverse?
      => false
      [4] pry(main)> Project.reflect_on_association(:pipelines).has_inverse?
      => :project
      ```
      
      After:
      
      ```
      [1] pry(main)> Ci::Build.reflect_on_association(:project).has_inverse?
      => :builds
      [2] pry(main)> Project.reflect_on_association(:builds).has_inverse?
      => :project
      [3] pry(main)> Ci::Pipeline.reflect_on_association(:project).has_inverse?
      => :pipelines
      [4] pry(main)> Project.reflect_on_association(:pipelines).has_inverse?
      => :project
      ```
      8ddb00ad
  8. Jan 05, 2018
  9. Jan 04, 2018
  10. Dec 22, 2017
  11. Dec 14, 2017
  12. Dec 07, 2017
  13. Dec 06, 2017
  14. Dec 05, 2017
  15. Dec 03, 2017
  16. Nov 27, 2017
  17. Nov 23, 2017
    • Sean McGivern's avatar
      Use latest_merge_request_diff association · 991bf24e
      Sean McGivern authored
      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.
      991bf24e
  18. Nov 16, 2017
  19. Nov 06, 2017
  20. Oct 06, 2017
Loading