Populate user_highest_roles table
What does this MR do?
Part of #118592 (closed)
Depends on !27231 (merged) and !28087 (merged) in order to keep the table up-to-date.
Populate the user_highest_roles
table with a background migration which schedules ~530 jobs with a 5 minutes gap to create an entry for each active User
(~5.3 million).
This is a suggestion from this comment in order to resolve performance issues when querying too much data.
Adds an index to the users table:
Up migration:
== 20200317110602 AddMigratingUserHighestRolesTableIndexToUsers: migrating ====
-- transaction_open?()
-> 0.0000s
-- index_exists?(:users, :id, {:where=>"state = 'active' AND user_type IS NULL AND bot_type IS NULL AND ghost IS NOT TRUE", :name=>"index_for_migrating_user_highest_roles_table", :algorithm=>:concurrently})
-> 0.0090s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- add_index(:users, :id, {:where=>"state = 'active' AND user_type IS NULL AND bot_type IS NULL AND ghost IS NOT TRUE", :name=>"index_for_migrating_user_highest_roles_table", :algorithm=>:concurrently})
-> 1.1810s
-- execute("RESET ALL")
-> 0.0003s
== 20200317110602 AddMigratingUserHighestRolesTableIndexToUsers: migrated (1.1906s)
Down migration:
== 20200317110602 AddMigratingUserHighestRolesTableIndexToUsers: reverting ====
-- transaction_open?()
-> 0.0000s
-- index_exists?(:users, :id, {:name=>"index_for_migrating_user_highest_roles_table", :algorithm=>:concurrently})
-> 0.0105s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- remove_index(:users, {:name=>"index_for_migrating_user_highest_roles_table", :algorithm=>:concurrently, :column=>:id})
-> 0.0175s
-- execute("RESET ALL")
-> 0.0002s
== 20200317110602 AddMigratingUserHighestRolesTableIndexToUsers: reverted (0.0287s)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Corinna Gogolok