Looks good!
Ci::ProcessBuildService#execute is just an elaborate routing helper to
different state machine events. All state machine event callbacks are
already in transactions, so the outer transaction is redundant. By
switching to a plain retry_lock, we can benefit from the optimizations
introduced in
!225133
This change is disabled by default, behind the feature flag
ci_pipeline_processing_atomic_processing_service_plain_retry_lock.
| Before | After |
|---|---|
Feature.enable(:ci_pipeline_processing_atomic_processing_service_plain_retry_lock)
precompute_pending_build_args flag, as this is a related flag that we are also rolling out
Feature.enable(:precompute_pending_build_args)
Expected results: Both pipelines should run to completion
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Replaces the custom in_partition lambda + partition_foreign_key pattern with Rails 7.1 native composite foreign keys for all relations between Ci::Pipeline and CommitStatus/Ci::Build/Ci::Processable/Ci::Bridge.
This is MR 1 of a series to address #431734.
Before:
has_many :statuses, ->(pipeline) { in_partition(pipeline) },
class_name: 'CommitStatus', foreign_key: :commit_id,
inverse_of: :pipeline, partition_foreign_key: :partition_id
After:
has_many :statuses,
class_name: 'CommitStatus',
foreign_key: [:commit_id, :partition_id],
primary_key: [:id, :partition_id],
inverse_of: :pipeline
For relations with additional scopes (e.g. .latest, .order(...)), the lambda is retained for the extra scoping only, with the in_partition call removed.
| File | Changes |
|---|---|
app/models/commit_status.rb |
belongs_to :pipeline updated |
app/models/ci/build.rb |
belongs_to :pipeline updated |
app/models/ci/pipeline.rb |
~25 has_many relations updated |
Closes #431734 (partially)
Part of &11812 maintenance::refactor,CI data partitioning,Category:Continuous Integration
Replaces the custom in_partition lambda + partition_foreign_key pattern with Rails 7.1 native composite foreign keys for all relations between Ci::Pipeline Ci::Stage and Ci::Stage CommitStatus/Ci::Build/Ci::Bridge.
This is MR 2 of a series to address #431734. Depends on !226893.
| File | Relation | Type |
|---|---|---|
app/models/ci/pipeline.rb |
has_many :stages |
Pipeline → Stage |
app/models/ci/stage.rb |
belongs_to :pipeline |
Stage → Pipeline |
app/models/ci/stage.rb |
has_many :statuses |
Stage → CommitStatus |
app/models/ci/stage.rb |
has_many :latest_statuses |
Stage → CommitStatus |
app/models/ci/stage.rb |
has_many :retried_statuses |
Stage → CommitStatus |
app/models/ci/stage.rb |
has_many :processables |
Stage → Processable |
app/models/ci/stage.rb |
has_many :builds |
Stage → Build |
app/models/ci/stage.rb |
has_many :bridges |
Stage → Bridge |
app/models/ci/stage.rb |
has_many :generic_commit_statuses |
Stage → GenericCommitStatus |
app/models/commit_status.rb |
belongs_to :ci_stage |
CommitStatus → Stage |
Closes #431734 (partially)
Part of &11812
Removes the custom ActiveRecord patches in gems/activerecord-gitlab that were used to support the partition_foreign_key option on associations and the query_constraints backport.
These patches are no longer needed because:
foreign_key: [:fk, :partition_id], primary_key: [:id, :partition_id]) instead of the custom in_partition lambda + partition_foreign_key pattern.query_constraints, making the Base patch redundant.This is MR 7 (final cleanup) of a series to address #431734.
This MR must be merged AFTER all 6 model MRs:
gems/activerecord-gitlab/lib/active_record/gitlab_patches/partitioning.rb (entry point)gems/activerecord-gitlab/lib/active_record/gitlab_patches/partitioning/base.rb (query_constraints backport)gems/activerecord-gitlab/lib/active_record/gitlab_patches/partitioning/associations/builder/association.rbgems/activerecord-gitlab/lib/active_record/gitlab_patches/partitioning/reflection/abstract_reflection.rbgems/activerecord-gitlab/lib/active_record/gitlab_patches/partitioning/reflection/association_reflection.rbgems/activerecord-gitlab/lib/active_record/gitlab_patches/partitioning/reflection/macro_reflection.rbgems/activerecord-gitlab/spec/active_record/gitlab_patches/partitioning/
gems/activerecord-gitlab/lib/active_record/gitlab_patches.rb (removed require)The in_partition scope in app/models/concerns/ci/partitionable.rb is kept because it is still used in non-association contexts.
Closes #431734
Part of &11812
Replaces the custom in_partition lambda + partition_foreign_key pattern with Rails 7.1 native composite foreign keys for all remaining job-level relations on Ci::Build and Ci::Processable, and their corresponding child models.
This is MR 6 (final) of a series to address #431734.
Depends on !226893.
| File | Relation | Type |
|---|---|---|
app/models/ci/build.rb |
has_many :inputs |
Build → JobInput |
app/models/ci/build.rb |
has_many :job_annotations |
Build → JobAnnotation |
app/models/ci/build.rb |
has_many :taggings |
Build → BuildTag |
app/models/ci/processable.rb |
has_one :job_definition_instance |
Processable → JobDefinitionInstance |
app/models/ci/processable.rb |
has_one :job_definition (through) |
Processable → JobDefinition |
app/models/ci/processable.rb |
has_many :job_messages |
Processable → JobMessage |
app/models/ci/processable.rb |
has_many :error_job_messages |
Processable → JobMessage |
app/models/ci/processable.rb |
has_one :job_source |
Processable → BuildSource |
app/models/ci/build_need.rb |
belongs_to :build |
BuildNeed → Processable |
app/models/ci/build_source.rb |
belongs_to :job |
BuildSource → Processable |
app/models/ci/build_tag.rb |
belongs_to :build |
BuildTag → Build |
app/models/ci/build_name.rb |
belongs_to :build |
BuildName → Build |
app/models/ci/job_annotation.rb |
belongs_to :job |
JobAnnotation → Build |
app/models/ci/job_message.rb |
belongs_to :job |
JobMessage → Processable |
app/models/ci/job_input.rb |
belongs_to :job |
JobInput → Build |
app/models/ci/job_definition_instance.rb |
belongs_to :job |
JobDefinitionInstance → Processable |
app/models/ci/job_definition_instance.rb |
belongs_to :job_definition |
JobDefinitionInstance → JobDefinition |
app/models/ci/unit_test_failure.rb |
belongs_to :build |
UnitTestFailure → Build |
Closes #431734
Part of &11812
Replaces the custom in_partition lambda + partition_foreign_key pattern with Rails 7.1 native composite foreign keys for all relations between Ci::Build and its trace/metadata/state child models.
This is MR 5 of a series to address #431734. Depends on !226893.
| File | Relation | Type |
|---|---|---|
app/models/ci/build.rb |
has_many :trace_chunks |
Build → BuildTraceChunk |
app/models/ci/build.rb |
has_one :runner_manager_build |
Build → RunnerManagerBuild |
app/models/ci/build_trace_chunk.rb |
belongs_to :build |
BuildTraceChunk → Build |
app/models/ci/build_trace_metadata.rb |
belongs_to :build |
BuildTraceMetadata → Build |
app/models/ci/build_trace_metadata.rb |
belongs_to :trace_artifact |
BuildTraceMetadata → JobArtifact |
app/models/ci/build_metadata.rb |
belongs_to :build |
BuildMetadata → CommitStatus |
app/models/ci/build_pending_state.rb |
belongs_to :build |
BuildPendingState → Build |
app/models/ci/build_report_result.rb |
belongs_to :build |
BuildReportResult → Build |
app/models/ci/running_build.rb |
belongs_to :build |
RunningBuild → Build |
app/models/ci/pending_build.rb |
belongs_to :build |
PendingBuild → Build |
Closes #431734 (partially)
Part of &11812
Replaces the custom in_partition lambda + partition_foreign_key pattern with Rails 7.1 native composite foreign keys for all relations in the Build Ci::JobArtifactReport and the EE Geo::JobArtifactState.
This is MR 4 of a series to address #431734. Depends on !226893.
| File | Relation | Type |
|---|---|---|
app/models/ci/build.rb |
has_many :job_artifacts |
Build → JobArtifact |
app/models/ci/build.rb |
has_one :job_artifacts_* (dynamic, per file type) |
Build → JobArtifact |
app/models/ci/job_artifact.rb |
belongs_to :job |
JobArtifact → Build |
app/models/ci/job_artifact.rb |
has_one :artifact_report |
JobArtifact → JobArtifactReport |
app/models/ci/job_artifact_report.rb |
belongs_to :job_artifact |
JobArtifactReport → JobArtifact |
ee/app/models/ee/ci/job_artifact.rb |
has_one :job_artifact_state |
JobArtifact → Geo::JobArtifactState |
Closes #431734 (partially)
Part of &11812
Replaces the custom in_partition lambda + partition_foreign_key pattern with Rails 7.1 native composite foreign keys for relations between Ci::Pipeline Ci::PipelineVariable, Ci::Pipeline/Ci::Build Ci::BuildExecutionConfig, Ci::Pipeline Ci::Workloads::Workload, and Ci::Workloads::Workload Ci::Workloads::VariableInclusions.
This is MR 3 of a series to address #431734. Depends on !226893.
| File | Relation | Type |
|---|---|---|
app/models/ci/pipeline.rb |
has_many :variables |
Pipeline → PipelineVariable |
app/models/ci/pipeline.rb |
has_one :workload |
Pipeline → Workload |
app/models/ci/pipeline_variable.rb |
belongs_to :pipeline |
PipelineVariable → Pipeline |
app/models/ci/build_execution_config.rb |
belongs_to :pipeline |
BuildExecutionConfig → Pipeline |
app/models/ci/build_execution_config.rb |
has_many :builds |
BuildExecutionConfig → Build |
app/models/ci/build.rb |
belongs_to :execution_config |
Build → BuildExecutionConfig |
app/models/ci/workloads/workload.rb |
has_many :variable_inclusions |
Workload → VariableInclusions |
Closes #431734 (partially)
Part of &11812
@stejacks-gitlab I don't think we can't answer any of those questions(reliably) with our current capabilities, but it will be easier with https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/ci_job_telemetry/
Revert "Merge branch 'kerrizor/add-find_by_id_through_partition' into 'master'"
This reverts merge request !227539 because is no longer needed thanks to !227689
| Before | After |
|---|---|
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Marius Bobin (52535665) at 18 Mar 11:15
Revert "Merge branch 'kerrizor/add-find_by_id_through_partition' in...
Revert "Merge branch 'mb-partition-query' into 'master'"
This reverts merge request !227525 because is no longer needed thanks to !227689
| Before | After |
|---|---|
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Marius Bobin (cefac2ec) at 18 Mar 11:11
Revert "Merge branch 'mb-partition-query' into 'master'"
Marius Bobin (7f77c523) at 18 Mar 10:36
Add feature flags and limit scope
@stomlinson @mfanGitLab I had to push !227689 (62a3e279) to fix the tests.
Marius Bobin (62a3e279) at 17 Mar 17:35
Fix tests and apply reviewer feedback
@pedropombeiro I'm going to merge this as is because we need it to mitigate the incident.
We're not updating the records, so what's the point?
I don't think it's needed because we do use it in the app and should be hit by those tests. Pipeline here is just an example of a partitionable resource, it doesn't mean that we want to test it on all of them.