Skip to content

Draft: Fix gitlab:setup pipeline failure about 24_forks.rb

What does this MR do and why?

There is a failed job in JiHu side. https://jihulab.com/gitlab-cn/gitlab/-/jobs/6578960

I tried to replicate this bug and found that sometimes the fork failed, resulting in a failure to call the _run_after_commit_queue method.

# db/fixtures/development/24_forks.rb

      Sidekiq::Worker.skipping_transaction_check do
        fork_project = Projects::ForkService.new(
          source_project,
          user,
          namespace: user.namespace,
          skip_disk_validation: true
        ).execute

        # Seed-Fu runs this entire fixture in a transaction, so the `after_commit`
        # hook won't run until after the fixture is loaded. That is too late
        # since the Sidekiq::Testing block has already exited. Force clearing
        # the `after_commit` queue to ensure the job is run now.
        fork_project.send(:_run_after_commit_queue)
        fork_project.import_state.send(:_run_after_commit_queue)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Change the line 169 of db/fixtures/development/03_project.rb to visibility_level: 20,.
  2. Run force=yes SIZE=1 FIXTURE_PATH="db/fixtures/development" bundle exec rake gitlab:setup several times locally.
  3. You will receive this error NoMethodError: undefined method _run_after_commit_queue' for nil:NilClass`.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports