spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb failed in JH side
On the JH side, we recently experienced a failure of this test
Failures:
1) Gitlab::BackgroundMigration::BackfillImportedIssueSearchData when issue has no search data record creates search data records
Failure/Error:
expect { perform_migration }
.to change { issue_search_data_table.count }.from(0).to(1)
expected `issue_search_data_table.count` to have changed from 0 to 1, but did not change
# ./spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb:59:in `block (3 levels) in <main>'
# ./spec/spec_helper.rb:418:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:409:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:405:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:52:in `with_raw_context'
# ./spec/spec_helper.rb:405:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:263:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <main>'
# ./spec/support/database_cleaner.rb:42: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>'
# ./jh/spec/spec_helper.rb:37:in `block (2 levels) in <main>'
2) Gitlab::BackgroundMigration::BackfillImportedIssueSearchData error handling skips insertion for that issue but continues with migration
Failure/Error: expect { perform_migration }.to change { issue_search_data_table.count }.from(0).to(1)
expected `issue_search_data_table.count` to have changed from 0 to 1, but did not change
# ./spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb:92:in `block (3 levels) in <main>'
# ./spec/spec_helper.rb:418:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:409:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:405:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:52:in `with_raw_context'
# ./spec/spec_helper.rb:405:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:263:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <main>'
# ./spec/support/database_cleaner.rb:42: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>'
# ./jh/spec/spec_helper.rb:37:in `block (2 levels) in <main>'
3) Gitlab::BackgroundMigration::BackfillImportedIssueSearchData error handling re-raises exceptions
Failure/Error: expect { perform_migration }.to raise_error(ActiveRecord::StatementTimeout)
expected ActiveRecord::StatementTimeout but nothing was raised
# ./spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb:103:in `block (3 levels) in <main>'
# ./spec/spec_helper.rb:418:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:409:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:405:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:52:in `with_raw_context'
# ./spec/spec_helper.rb:405:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:263:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <main>'
# ./spec/support/database_cleaner.rb:42: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>'
# ./jh/spec/spec_helper.rb:37:in `block (2 levels) in <main>'
Finished in 37.96 seconds (files took 37.64 seconds to load)
3 examples, 3 failures
Failed examples:
rspec ./spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb:58 # Gitlab::BackgroundMigration::BackfillImportedIssueSearchData when issue has no search data record creates search data records
rspec ./spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb:85 # Gitlab::BackgroundMigration::BackfillImportedIssueSearchData error handling skips insertion for that issue but continues with migration
rspec ./spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb:98 # Gitlab::BackgroundMigration::BackfillImportedIssueSearchData error handling re-raises exceptions
I tried to find out the cause of the failure and found that the problem was roughly in this place
let(:migration) do
described_class.new(start_id: 1,
end_id: 30,
batch_table: :issues,
batch_column: :id,
sub_batch_size: 2,
pause_ms: 0,
connection: ApplicationRecord.connection)
end
Once the id of an issue exceeds 30, the test fails.