Set p_ci_build_trace_metadata to detach archived partitions

What does this MR do and why?

This MR sets the p_ci_build_trace_metadata table to be partitioned with detach_archived: true, and adds the partitioning shared examples to the model spec.

The change is a one-line configuration change in Ci::BuildTraceMetadata:

partitionable scope: :build, partitioned: { detach_archived: true }

This lets GitLab detach a partition when it archives the pipeline, instead of deleting each record one by one.

Why: The p_ci_build_trace_metadata table grows too fast on GitLab.com. The table holds trace-archival processing data that GitLab uses to check that each trace is archived correctly. After the trace is uploaded to object storage, no code uses the data. The table is already partitioned, so GitLab can keep the records until it archives the pipeline, then detach/truncate the whole partition. This saves database capacity.

Tests: Adds the a CI model that detaches archived partitions shared examples to spec/models/ci/build_trace_metadata_spec.rb, matching the pattern already used by Ci::PipelineProcessingData, Ci::JobDefinition, and Ci::JobDefinitionInstance. This is placed at the top level of the spec (consistent with those other models) rather than inside the existing partitioning block, so the shared example is not affected by that block's stub_current_partition_id setup.

References

Screenshots or screen recordings

N/A — backend model configuration change, no UI.

How to set up and validate locally

  1. Run the model spec:
    bundle exec rspec spec/models/ci/build_trace_metadata_spec.rb
  2. Confirm the partitioning shared examples (a CI model that detaches archived partitions) pass.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading