Fixes rollback not working for AtomicInternalId in decomposed model
What does this MR do and why?
Fixes a spec failing when fully decomposed. Extracted from !78182 (merged)
To reproduce:
-
Configure multiple databases following https://docs.gitlab.com/ee/development/database/multiple_databases.html#development-setup
-
Configure fully decomposed with:
export GITLAB_USE_MODEL_LOAD_BALANCING=true
-
Run the spec:
bin/rspec spec/models/ci/pipeline_spec.rb -e AtomicInternalId
This fails on master
with:
Failures:
1) Ci::Pipeline modules behaves like AtomicInternalId .has_internal_id unsetting the instance internal id on rollback when the internal id has been changed when the internal id is automatically set clears it on the instance
Failure/Error: expect(read_internal_id).to be_nil
expected: nil
got: 2
Shared Example Group: "AtomicInternalId" called from ./spec/models/ci/pipeline_spec.rb:703
# ./spec/support/shared_examples/models/atomic_internal_id_shared_examples.rb:127:in `block (6 levels) in <main>'
# ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:401:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:397:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:45:in `with_raw_context'
# ./spec/spec_helper.rb:397:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <main>'
Finished in 1 minute 23.45 seconds (files took 9.15 seconds to load)
15 examples, 1 failure, 2 pending
Failed examples:
rspec ./spec/models/ci/pipeline_spec.rb[1:58:1:1:5:1:1:1] # Ci::Pipeline modules behaves like AtomicInternalId .has_internal_id unsetting the instance internal id on rollback when the internal id has been changed when the internal id is automatically set clears it on the instance
But passes with this fix.
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Thong Kuah