Commit 90047e90 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'revert-4a3dbc31' into 'master'

Revert "Merge branch 'stuck-ci-jobs-worker-optimize-running' into 'master'"

See merge request gitlab-org/gitlab!69163
parents 4a3dbc31 af23fa47
......@@ -58,8 +58,8 @@ class CommitStatus < Ci::ApplicationRecord
scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) }
scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) }
scope :with_pipeline, -> { joins(:pipeline) }
scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) }
scope :updated_at_before, ->(date) { where('ci_builds.updated_at < ?', date) }
scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) }
scope :updated_before, ->(lookback:, timeout:) {
where('(ci_builds.created_at BETWEEN ? AND ?) AND (ci_builds.updated_at BETWEEN ? AND ?)', lookback, timeout, lookback, timeout)
}
......
......@@ -63,12 +63,10 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
end
def running_timed_out_builds
if Feature.enabled?(:ci_new_query_for_running_stuck_jobs)
running_builds = Ci::Build.running.created_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago).order(created_at: :asc, project_id: :asc) # rubocop: disable CodeReuse/ActiveRecord
Ci::Build.id_in(running_builds).updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
else
Ci::Build.running.updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
end
Ci::Build.running.where( # rubocop: disable CodeReuse/ActiveRecord
'ci_builds.updated_at < ?',
BUILD_RUNNING_OUTDATED_TIMEOUT.ago
)
end
def try_obtain_lease
......
---
name: ci_new_query_for_running_stuck_jobs
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68891
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339264
milestone: '14.3'
type: development
group: group::pipeline execution
default_enabled: false
......@@ -186,7 +186,6 @@ RSpec.describe StuckCiJobsWorker do
end
end
shared_examples 'job is running' do
context 'when job is running' do
let(:status) { 'running' }
......@@ -202,17 +201,6 @@ RSpec.describe StuckCiJobsWorker do
it_behaves_like 'job is unchanged'
end
end
end
it_behaves_like 'job is running'
context 'when ci_new_query_for_running_stuck_jobs feature flag is disabled' do
before do
stub_feature_flags(ci_new_query_for_running_stuck_jobs: false)
end
it_behaves_like 'job is running'
end
%w(success skipped failed canceled).each do |status|
context "when job is #{status}" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment