BigW Consortium Gitlab
This commit introduces the usage of Common Table Expressions (CTEs) to efficiently retrieve nested group hierarchies, without having to rely on the "routes" table (which is an _incredibly_ inefficient way of getting the data). This requires a patch to ActiveRecord (found in the added initializer) to work properly as ActiveRecord doesn't support WITH statements properly out of the box. Unfortunately MySQL provides no efficient way of getting nested groups. For example, the old routes setup could easily take 5-10 seconds depending on the amount of "routes" in a database. Providing vastly different logic for both MySQL and PostgreSQL will negatively impact the development process. Because of this the various nested groups related methods return empty relations when used in combination with MySQL. For project authorizations the logic is split up into two classes: * Gitlab::ProjectAuthorizations::WithNestedGroups * Gitlab::ProjectAuthorizations::WithoutNestedGroups Both classes get the fresh project authorizations (= as they should be in the "project_authorizations" table), including nested groups if PostgreSQL is used. The logic of these two classes is quite different apart from their public interface. This complicates development a bit, but unfortunately there is no way around this. This commit also introduces Gitlab::GroupHierarchy. This class can be used to get the ancestors and descendants of a base relation, or both by using a UNION. This in turn is used by methods such as: * Namespace#ancestors * Namespace#descendants * User#all_expanded_groups Again this class relies on CTEs and thus only works on PostgreSQL. The Namespace methods will return an empty relation when MySQL is used, while User#all_expanded_groups will return only the groups a user is a direct member of. Performance wise the impact is quite large. For example, on GitLab.com Namespace#descendants used to take around 580 ms to retrieve data for a particular user. Using CTEs we are able to reduce this down to roughly 1 millisecond, returning the exact same data. == On The Fly Refreshing Refreshing of authorizations on the fly (= when users.authorized_projects_populated was not set) is removed with this commit. This simplifies the code, and ensures any queries used for authorizations are not mutated because they are executed in a Rails scope (e.g. Project.visible_to_user). This commit includes a migration to schedule refreshing authorizations for all users, ensuring all of them have their authorizations in place. Said migration schedules users in batches of 5000, with 5 minutes between every batch to smear the load around a bit. == Spec Changes This commit also introduces some changes to various specs. For example, some specs for ProjectTeam assumed that creating a personal project would _not_ lead to the owner having access, which is incorrect. Because we also no longer refresh authorizations on the fly for new users some code had to be added to the "empty_project" factory. This chunk of code ensures that the owner's permissions are refreshed after creating the project, something that is normally done in Projects::CreateService.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
blob_viewer | Loading commit data... | |
ci | Loading commit data... | |
concerns | Loading commit data... | |
cycle_analytics | Loading commit data... | |
hooks | Loading commit data... | |
issue | Loading commit data... | |
members | Loading commit data... | |
merge_request | Loading commit data... | |
network | Loading commit data... | |
project_services | Loading commit data... | |
protected_branch | Loading commit data... | |
ability_spec.rb | Loading commit data... | |
abuse_report_spec.rb | Loading commit data... | |
appearance_spec.rb | Loading commit data... | |
application_setting_spec.rb | Loading commit data... | |
award_emoji_spec.rb | Loading commit data... | |
blob_spec.rb | Loading commit data... | |
board_spec.rb | Loading commit data... | |
broadcast_message_spec.rb | Loading commit data... | |
chat_name_spec.rb | Loading commit data... | |
chat_team_spec.rb | Loading commit data... | |
commit_range_spec.rb | Loading commit data... | |
commit_spec.rb | Loading commit data... | |
commit_status_spec.rb | Loading commit data... | |
compare_spec.rb | Loading commit data... | |
container_repository_spec.rb | Loading commit data... | |
deploy_key_spec.rb | Loading commit data... | |
deploy_keys_project_spec.rb | Loading commit data... | |
deployment_spec.rb | Loading commit data... | |
diff_discussion_spec.rb | Loading commit data... | |
diff_note_spec.rb | Loading commit data... | |
discussion_spec.rb | Loading commit data... | |
email_spec.rb | Loading commit data... | |
environment_spec.rb | Loading commit data... | |
event_spec.rb | Loading commit data... | |
external_issue_spec.rb | Loading commit data... | |
forked_project_link_spec.rb | Loading commit data... | |
generic_commit_status_spec.rb | Loading commit data... | |
global_milestone_spec.rb | Loading commit data... | |
group_label_spec.rb | Loading commit data... | |
group_milestone_spec.rb | Loading commit data... | |
group_spec.rb | Loading commit data... | |
guest_spec.rb | Loading commit data... | |
identity_spec.rb | Loading commit data... | |
issue_collection_spec.rb | Loading commit data... | |
issue_spec.rb | Loading commit data... | |
key_spec.rb | Loading commit data... | |
label_link_spec.rb | Loading commit data... | |
label_priority_spec.rb | Loading commit data... | |
label_spec.rb | Loading commit data... | |
legacy_diff_discussion_spec.rb | Loading commit data... | |
lfs_objects_project_spec.rb | Loading commit data... | |
list_spec.rb | Loading commit data... | |
member_spec.rb | Loading commit data... | |
merge_request_diff_spec.rb | Loading commit data... | |
merge_request_spec.rb | Loading commit data... | |
milestone_spec.rb | Loading commit data... | |
namespace_spec.rb | Loading commit data... | |
note_spec.rb | Loading commit data... | |
notification_setting_spec.rb | Loading commit data... | |
pages_domain_spec.rb | Loading commit data... | |
personal_access_token_spec.rb | Loading commit data... | |
project_authorization_spec.rb | Loading commit data... | |
project_feature_spec.rb | Loading commit data... | |
project_group_link_spec.rb | Loading commit data... | |
project_label_spec.rb | Loading commit data... | |
project_snippet_spec.rb | Loading commit data... | |
project_spec.rb | Loading commit data... | |
project_statistics_spec.rb | Loading commit data... | |
project_team_spec.rb | Loading commit data... | |
project_wiki_spec.rb | Loading commit data... | |
protectable_dropdown_spec.rb | Loading commit data... | |
protected_branch_spec.rb | Loading commit data... | |
protected_tag_spec.rb | Loading commit data... | |
redirect_route_spec.rb | Loading commit data... | |
release_spec.rb | Loading commit data... | |
repository_spec.rb | Loading commit data... | |
route_spec.rb | Loading commit data... | |
sent_notification_spec.rb | Loading commit data... | |
service_spec.rb | Loading commit data... | |
snippet_blob_spec.rb | Loading commit data... | |
snippet_spec.rb | Loading commit data... | |
spam_log_spec.rb | Loading commit data... | |
subscription_spec.rb | Loading commit data... | |
system_note_metadata_spec.rb | Loading commit data... | |
timelog_spec.rb | Loading commit data... | |
todo_spec.rb | Loading commit data... | |
tree_spec.rb | Loading commit data... | |
trending_project_spec.rb | Loading commit data... | |
upload_spec.rb | Loading commit data... | |
user_agent_detail_spec.rb | Loading commit data... | |
user_spec.rb | Loading commit data... | |
wiki_directory_spec.rb | Loading commit data... | |
wiki_page_spec.rb | Loading commit data... |