Skip to content
Snippets Groups Projects

Fix query timeout when finding auto-cancelable pipelines

Merged Fabio Pitino requested to merge fix-timeout-auto-cancelable-pipelines into master
All threads resolved!
Files
4
+ 20
4
@@ -845,9 +845,15 @@ def all_merge_requests_by_recency
end
def same_family_pipeline_ids
::Gitlab::Ci::PipelineObjectHierarchy.new(
base_and_ancestors(same_project: true), options: { same_project: true }
).base_and_descendants.select(:id)
if Feature.enabled?(:ci_root_ancestor_for_pipeline_family, project, default_enabled: false)
::Gitlab::Ci::PipelineObjectHierarchy.new(
self.class.where(id: root_ancestor), options: { same_project: true }
).base_and_descendants.select(:id)
else
::Gitlab::Ci::PipelineObjectHierarchy.new(
base_and_ancestors(same_project: true), options: { same_project: true }
).base_and_descendants.select(:id)
end
end
def build_with_artifacts_in_self_and_descendants(name)
@@ -869,6 +875,15 @@ def self_and_descendants
.base_and_descendants
end
def root_ancestor
return self unless child?
Gitlab::Ci::PipelineObjectHierarchy
.new(self.class.unscoped.where(id: id), options: { same_project: true })
.base_and_ancestors(hierarchy_order: :desc)
.first
end
def bridge_triggered?
source_bridge.present?
end
@@ -878,7 +893,8 @@ def bridge_waiting?
end
def child?
parent_pipeline.present?
parent_pipeline? && # child pipelines have `parent_pipeline` source
parent_pipeline.present?
end
def parent?
Loading