Skip to content
Snippets Groups Projects

Make Gitlab::BackgroundMigration.remaining work across queues

Merged Sean McGivern requested to merge background-migration-remaining-queue into master
1 unresolved thread

With worker routing, a Sidekiq queue can have jobs from multiple workers. This meant Gitlab::BackgroundMigration.remaining needed to account for that possibility. We do that in the same way as we already did with the scheduled, retry, and dead sets: iterate through and look for matching records.

To test, you can add this under sidekiq in config/gitlab.yml:

routing_rules: [['*', 'default']]

This makes every worker go to the default queue. Then, in a console (without Sidekiq running!):

[1] pry(main)> BackgroundMigrationWorker.queue
=> "default"
[2] pry(main)> BackgroundMigrationWorker.perform_async('Foo')
=> "237f3d21f4afe9606761b826"
[3] pry(main)> BackgroundMigrationWorker.perform_in(10.minutes, 'Foo')
=> "132fb9bc94011f6ccaeb668c"
[4] pry(main)> BackgroundMigrationWorker.perform_in(10.minutes, 'Foo')
=> "068c76b285a9cf9ebad6cdee"
[5] pry(main)> Gitlab::BackgroundMigration.remaining
=> 3

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • A deleted user added databasereview pending label
  • A deleted user added backend database documentation labels
  • 1 Message
    :book: This merge request adds or changes documentation files. A review from the Technical Writing team before you merge is recommended. Reviews can happen after you merge.

    Documentation review

    The following files require a review from a technical writer:

    • doc/update/index.md

    The review does not need to block merging this merge request. See the:

    Reviewer roulette

    Changes that require review have been detected!

    Please refer to the table below for assigning reviewers and maintainers suggested by Danger in the specified category:

    Category Reviewer Maintainer
    backend George Koltsov (@georgekoltsov) (UTC+1, same timezone as @smcgivern) Heinrich Lee Yu (@engwan) (UTC+8, 7 hours ahead of @smcgivern)
    database Simon Tomlinson (@stomlinson) (UTC-5, 6 hours behind @smcgivern) Mayra Cabrera (@mayra-cabrera) (UTC-5, 6 hours behind @smcgivern)

    To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.

    To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.

    Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.

    If needed, you can retry the danger-review job that generated this comment.

    Generated by :no_entry_sign: Danger

  • Sean McGivern added 1 commit

    added 1 commit

    • fcc0748d - Make Gitlab::BackgroundMigration.remaining work across queues

    Compare with previous version

  • Sean McGivern requested review from @qmnguyen0711

    requested review from @qmnguyen0711

  • Sean McGivern added 1 commit

    added 1 commit

    • d20d8748 - Make Gitlab::BackgroundMigration.remaining work across queues

    Compare with previous version

  • Sean McGivern added 1 commit

    added 1 commit

    • b086b148 - Make Gitlab::BackgroundMigration.remaining work across queues

    Compare with previous version

  • Sean McGivern requested review from @mwoolf and removed review request for @qmnguyen0711

    requested review from @mwoolf and removed review request for @qmnguyen0711

  • Max Woolf approved this merge request

    approved this merge request

  • Max Woolf removed review request for @mwoolf

    removed review request for @mwoolf

    • Resolved by Max Woolf

      :wave: @mwoolf, thanks for approving this merge request.

      Please consider starting a new pipeline if:

      • This is the first time the merge request is approved, or
      • The merge request is ready to be merged, and there has not been a merge request pipeline in the last 2 hours.

      For more info, refer to the guideline.

  • requested review from @mayra-cabrera

  • Mayra Cabrera approved this merge request

    approved this merge request

  • 86 86
    87 87 **For Omnibus installations**
    88 88
    89 If using GitLab 12.9 and newer, also run:
    89 You can also run:
    90 90
    91 91 ```shell
    92 92 sudo gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
    93 93 ```
    94 94
    95 If using GitLab 12.8 and older, run the following using a [Rails console](../administration/operations/rails_console.md#starting-a-rails-console-session):
    96
    97 ```ruby
    98 puts Sidekiq::Queue.new("background_migration").size
    99 Sidekiq::ScheduledSet.new.select { |r| r.klass == 'BackgroundMigrationWorker' }.size
    100 ```
    • Are these still accurate? If so, it'd be a good idea to leave them as guidance for people that do not have admin access.

    • Author Contributor

      @mayra-cabrera these instructions are accurate to a point if you're using an old GitLab version. But this version is so old that we don't have to keep it in the docs any more?

      They will also become inaccurate if you use routing rules to change where background migrations run, unlike Gitlab::BackgroundMigration.remaining, which (thanks to this MR), will just work.

    • Please register or sign in to reply
  • Mayra Cabrera resolved all threads

    resolved all threads

  • Mayra Cabrera enabled an automatic merge when the pipeline for 01556dde succeeds

    enabled an automatic merge when the pipeline for 01556dde succeeds

  • merged

  • Mayra Cabrera mentioned in commit cb46d5b0

    mentioned in commit cb46d5b0

  • added workflowcanary label and removed workflowstaging label

  • added workflowproduction label and removed workflowcanary label

  • added typemaintenance label and removed tooling (archive) label

  • Please register or sign in to reply
    Loading