Skip to content

Drop the use of namespace in Sidekiq and Mailroom delivery

Sylvester Chin requested to merge sc1-deprecate-namespace into master

What does this MR do and why?

This MR drops the use of namespace in Redis for Sidekiq and Mailroom delivery.

See gitlab-com/gl-infra/scalability#2288 (closed)

Screenshots or screen recordings

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

Before After

How to set up and validate locally

Part 1: running on master branch with namespace

  1. Start gdk using gdk start. Stop background jobs using gdk stop rails-background-jobs
  2. Open a rails console with gdk rails c and run a dummy job
[1] pry(main)> Chaos::SleepWorker.perform_async(13)
=> "e9611e428695bd51b893329b"
[2] pry(main)> Chaos::SleepWorker.perform_in(10, 13)
=> "688b4fd43262db8245703120"
  1. Confirm on redis that namespaced queue is used.
➜  gitlab git:(master) ✗ gdk redis-cli -n 1 zcard resque:gitlab:schedule
(integer) 1
➜  gitlab git:(master) ✗ gdk redis-cli -n 1 llen resque:gitlab:queue:default
(integer) 1

Part 2: running this branch without namespace

  1. Restart gdk on this branch
> git checkout sc1-deprecate-namespace
> gdk restart
> gdk stop rails-background-jobs
  1. Open a rails console to test the enqueues
➜  gitlab git:(sc1-deprecate-namespace) ✗ gdk rails c
Loading development environment (Rails 7.0.8)
[1] pry(main)> Chaos::SleepWorker.perform_in(10, 13)
=> "6f7906d72972ab8773a979d2"
[2] pry(main)> Chaos::SleepWorker.perform_async(13)
=> "5db2e9d0abc57c37e2ba822d"
  1. Verify on Redis:
➜  gitlab git:(sc1-deprecate-namespace) ✗ gdk redis-cli -n 1
redis /Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket[1]> zcard schedule
(integer) 1
redis /Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket[1]> llen queue:default
(integer) 1

Part 3: Post-deploy Migration

  1. Run or redo the migration
bin/rails db:migrate:redo:main VERSION=20231003045342 RAILS_ENV=development 

bin/rails db:migrate:up:main VERSION=20231003045342 RAILS_ENV=development # run this if it is the first time
  1. Verify on Redis that the pdm moves namespaced jobs to non-namespaced data structures.
redis /Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket[1]> zcard resque:gitlab:schedule
(integer) 0
redis /Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket[1]> llen resque:gitlab:queue:default
(integer) 0
redis /Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket[1]> llen queue:default
(integer) 2
redis /Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket[1]> zcard schedule
(integer) 2

MR acceptance checklist

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

Edited by Sylvester Chin

Merge request reports