Skip to content

Always use generated queue name for worker matching

When we match against workers, the name attribute is tricky. It means the queue name, but which queue name?

  1. The actual queue name (after applying worker routing rules)?
  2. The generated queue name (based on the worker class name and queue namespace)?

Before this commit, it was 1, but that was confusing: it would start as default (before the attribute was set), then change to the generated queue name, then change again to the queue name based on worker routing rules. Because the routing rules are evaluated on application load, this was hard to debug and could give unexpected results.

Instead, we say that the name attribute always means item 2. This is also the name present in all_queues.yml, and this file is referenced in the documentation. That means it's more consistent and predictable, and doesn't require changes to the router itself.

For gitlab-com/gl-infra/scalability#1175 (closed).

Testing

A simple way of replicating the original issue is to add this to config/gitlab.yml under sidekiq:

routing_rules: [['name=project_import_schedule', null], ['*', 'default']]

Then:

# master
$ bundle exec rails r 'p [ProjectImportScheduleWorker, MergeWorker, PostReceive].map(&:queue)'
["default", "default", "default"]

# this branch
$ bundle exec rails r 'p [ProjectImportScheduleWorker, MergeWorker, PostReceive].map(&:queue)'
["project_import_schedule", "default", "default"]

Merge request reports