Commit c7e781d3 authored by charlie ablett's avatar charlie ablett

Merge branch 'always-persist-processed' into 'master'

Always persist `processed` of CommitStatus

See merge request gitlab-org/gitlab!33652
parents 4dc50578 c2074229
...@@ -94,6 +94,11 @@ class CommitStatus < ApplicationRecord ...@@ -94,6 +94,11 @@ class CommitStatus < ApplicationRecord
end end
before_save if: :status_changed?, unless: :importing? do before_save if: :status_changed?, unless: :importing? do
# we mark `processed` as always changed:
# another process might change its value and our object
# will not be refreshed to pick the change
self.processed_will_change!
if Feature.disabled?(:ci_atomic_processing, project) if Feature.disabled?(:ci_atomic_processing, project)
self.processed = nil self.processed = nil
elsif latest? elsif latest?
......
...@@ -96,6 +96,21 @@ describe CommitStatus do ...@@ -96,6 +96,21 @@ describe CommitStatus do
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
it "processed state is always persisted" do
commit_status.update!(retried: false, status: :pending)
# another process does mark object as processed
CommitStatus.find(commit_status.id).update_column(:processed, true)
# subsequent status transitions on the same instance
# always saves processed=false to DB even though
# the current value did not change
commit_status.update!(retried: false, status: :running)
# we look at a persisted state in DB
expect(CommitStatus.find(commit_status.id).processed).to eq(false)
end
end end
end end
......
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