Skip to content

Store pipeline counts by status

Adam Hegyi requested to merge 246847-store-pipeline-counts-by-status into master

What does this MR do?

This MR periodically stores pipeline counts by status for the instance statistics feature.

The change is behind a feature flag (store_ci_pipeline_counts_by_status) which is currently disabled by default.

In order to make counts efficient (BatchCount), an existing index had to be modified to include the id attribute.

The index creation took 17 minutes.

Queries

The queries are executed by BatchCount. The newly created index should cover all 4 cases (succeeded, failed, skipped, canceled).

SELECT MIN("ci_pipelines"."id") FROM "ci_pipelines" WHERE ("ci_pipelines"."status" IN ('canceled'))

Plan: https://explain.depesz.com/s/LHXG

SELECT MAX("ci_pipelines"."id") FROM "ci_pipelines" WHERE ("ci_pipelines"."status" IN ('canceled'))

Plan: https://explain.depesz.com/s/tHbu

SELECT COUNT("ci_pipelines"."id") FROM "ci_pipelines" WHERE ("ci_pipelines"."status" IN ('canceled')) AND "ci_pipelines"."id" BETWEEN 1200056 AND 1300055

Plan: https://explain.depesz.com/s/lAxd

GraphQL query for the counts

You can create seed data by running: FILTER=instance_statistics bundle exec rake db:seed_fu

{
  instanceStatisticsMeasurements(identifier: PIPELINES_SUCCEEDED) {
    nodes {
      count
      recordedAt
    }
  }
}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Counts are exposed for admins only.

Refs #246847 (closed)

Edited by Peter Leitzen

Merge request reports