Skip to content

Add daily group coverage data new finder

Max Orefice requested to merge mo-add-group-coverage-data-finder-2 into master

Ref: #293825 (closed)

This feature will be behind a feature flag called coverage_data_new_finder

This is Step #3 to refactor our daily coverage data finder.

What does this MR do?

This MR creates a new finder which refactors how we fetch our daily coverage data at the group level.

It includes the following items:

  • Extend EE finder with group filtering
  • Hook up new finder in controller

Why are we doing this?

As part of our effort to reduce our ~"technical debt", we are refactoring our daily coverage finder

This finder is used at 2 different places, so we decided to introduce a feature flag to mitigate the risk of ~performance degradation.

  1. Aggregate daily coverage by project - https://gitlab.com/gitlab-org/gitlab/-/graphs/master/charts
  2. Aggregate daily coverage by group - https://gitlab.com/groups/gitlab-org/-/analytics/repository_analytics

We recently added a new group_id column to fetch our data by group (!53494 (merged)) which is now used in this MR.

Database review

SQL Query

SELECT
    ci_daily_build_group_report_results.*
FROM
    ci_daily_build_group_report_results
WHERE
    ci_daily_build_group_report_results.group_id = 9970
    AND ((data -> 'coverage') IS NOT NULL)
    AND ci_daily_build_group_report_results.default_branch = TRUE
    AND ci_daily_build_group_report_results.date BETWEEN '2021-01-12'
    AND '2021-02-12'
ORDER BY
    ci_daily_build_group_report_results.date DESC,
    ci_daily_build_group_report_results.group_name ASC

Query plan

 Sort  (cost=3.47..3.47 rows=1 width=110) (actual time=2.313..2.314 rows=0 loops=1)
   Sort Key: ci_daily_build_group_report_results.date DESC, ci_daily_build_group_report_results.group_name
   Sort Method: quicksort  Memory: 25kB
   Buffers: shared hit=9 read=3
   I/O Timings: read=2.171
   ->  Index Scan using index_ci_daily_build_group_report_results_on_group_id on public.ci_daily_build_group_report_results  (cost=0.43..3.46 rows=1 width=110) (actual time=2.261..2.261 rows=0 loops=1)
         Index Cond: (ci_daily_build_group_report_results.group_id = 22)
         Filter: (ci_daily_build_group_report_results.default_branch AND ((ci_daily_build_group_report_results.data -> 'coverage'::text) IS NOT NULL) AND (ci_daily_build_group_report_results.date >= '2021-01-12'::date) AND (ci_daily_build_group_report_results.date <= '2021-02-12'::date))
         Rows Removed by Filter: 0
         Buffers: shared hit=3 read=3
         I/O Timings: read=2.171

Cold cache

Time: 683.913 ms
  - planning: 0.967 ms
  - execution: 682.946 ms (estimated* for prod: 0.000...0.677 s)
    - I/O read: 283.214 ms
    - I/O write: N/A

Shared buffers:
  - hits: 223 (~1.70 MiB) from the buffer pool
  - reads: 428 (~3.30 MiB) from the OS file cache, including disk I/O
  - dirtied: 306 (~2.40 MiB)
  - writes: 0

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Max Orefice

Merge request reports

Loading