Go to file
Yorick Peterse ac382b5682
Use CTEs for nested groups and authorizations
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.
2017-05-17 16:51:08 +02:00
.github
.gitlab Add summary lines for collapsed details in the bug report template 2017-05-11 11:21:16 +08:00
app Use CTEs for nested groups and authorizations 2017-05-17 16:51:08 +02:00
bin Add gitaly source installation instructions 2017-03-21 14:55:41 +01:00
builds
changelogs Merge branch 'allow_numeric_values_in_gitlab_ci_yml' into 'master' 2017-05-15 07:59:45 +00:00
config Use CTEs for nested groups and authorizations 2017-05-17 16:51:08 +02:00
db Use CTEs for nested groups and authorizations 2017-05-17 16:51:08 +02:00
doc Merge branch 'allow_numeric_values_in_gitlab_ci_yml' into 'master' 2017-05-15 07:59:45 +00:00
docker Update README.md 2016-10-13 14:43:05 +00:00
features Merge branch 'dm-wait-for-requests' into 'master' 2017-05-12 23:48:38 +00:00
fixtures/emojis Added emoji description title to award emoji buttons 2017-04-24 14:24:48 +01:00
generator_templates Add remove_concurrent_index to database helper 2017-04-06 09:53:57 +11:00
lib Use CTEs for nested groups and authorizations 2017-05-17 16:51:08 +02:00
locale Add German translation for Cycle Analytics (!11161) 2017-05-09 13:47:31 +02:00
log
public shows go back link only when history is available 2017-04-07 14:24:04 +00:00
qa Fix outdated 'Admin area' link label in GitLab QA 2017-04-12 10:57:34 +02:00
rubocop Add AddColumnWithDefaultToLargeTable cop 2017-04-28 15:55:55 -05:00
scripts Enable the Style/TrailingCommaInLiteral cop 2017-05-10 18:25:45 +02:00
shared Add GitLab Pages 2017-01-31 22:50:39 +00:00
spec Use CTEs for nested groups and authorizations 2017-05-17 16:51:08 +02:00
tmp Add gitaly source installation instructions 2017-03-21 14:55:41 +01:00
vendor Merge branch 'update-templates-for-9-2' into 'master' 2017-05-08 10:46:24 +00:00
.babelrc Update droplab 2017-04-07 13:57:03 +00:00
.csscomb.json
.eslintignore Started internationalising cycyle analytics 2017-04-15 16:07:31 +01:00
.eslintrc Add ES lint support to identify poorly written Promises 2017-04-20 11:11:51 +00:00
.flayignore [Issue sorting]Addressed review comments 2017-03-14 14:11:59 +02:00
.foreman
.gitignore Added balsamiq jasmine integration test 2017-05-15 07:48:54 +00:00
.gitlab-ci.yml Remove unnecessary cache definition in rake karma test 2017-05-11 12:17:07 -07:00
.haml-lint.yml HAMLLint: Enable `MultilinePipe` rule 2017-01-24 10:09:28 -08:00
.mailmap
.pkgr.yml
.rspec
.rubocop.yml Enable the Style/TrailingCommaInArguments cop 2017-05-10 18:25:45 +02:00
.rubocop_todo.yml Enable the Style/TrailingCommaInArguments cop 2017-05-10 18:25:45 +02:00
.ruby-version Bump ruby version 2016-12-03 15:57:20 +01:00
.scss-lint.yml Enable ColorVariable in scss-lint 2016-12-01 20:22:51 -05:00
CHANGELOG.md Update CHANGELOG.md for 9.1.4 2017-05-12 21:14:44 -03:00
CONTRIBUTING.md Remove FE team label 2017-05-05 15:31:14 +01:00
GITALY_SERVER_VERSION Re-enable Gitaly commit_raw_diff feature 2017-05-07 23:37:42 +02:00
GITLAB_PAGES_VERSION Use GitLab Pages v0.4.2 2017-05-05 19:16:04 +01:00
GITLAB_SHELL_VERSION Bump gitlab-shell version to 5.0.3 2017-04-25 21:48:02 +03:00
GITLAB_WORKHORSE_VERSION Use gitlab-workhorse 2.0.0 2017-05-03 16:22:05 +02:00
Gemfile Add support for deltas_only under Gitaly 2017-05-13 18:27:06 +02:00
Gemfile.lock Add support for deltas_only under Gitaly 2017-05-13 18:27:06 +02:00
LICENSE Update LICENSE to 2017 2017-02-08 22:58:40 +00:00
MAINTENANCE.md
PROCESS.md Improving copy of CONTRIBUTING.md, PROCESS.md, and code_review.md 2017-05-04 09:02:39 +02:00
Procfile remove changes to Procfile 2017-02-01 16:23:26 -06:00
README.md gitter badge in the readme pointing to gitlabhq/gitlabhq 2017-04-27 16:45:17 +01:00
Rakefile
VERSION Update VERSION to 9.2.0-pre 2017-04-22 09:57:26 -03:00
config.ru
doc_styleguide.md
docker-compose.yml
package.json Merge branch 'balsalmiq-support' into 'master' 2017-05-05 18:43:13 +00:00
yarn.lock Merge branch 'balsalmiq-support' into 'master' 2017-05-05 18:43:13 +00:00

README.md

GitLab

Build status Overall test coverage Code Climate Core Infrastructure Initiative Best Practices Gitter

Test coverage

  • Ruby coverage Ruby
  • JavaScript coverage JavaScript

Canonical source

The canonical source of GitLab Community Edition is hosted on GitLab.com.

Open source software to collaborate on code

To see how GitLab looks please see the features page on our website.

  • Manage Git repositories with fine grained access controls that keep your code secure
  • Perform code reviews and enhance collaboration with merge requests
  • Complete continuous integration (CI) and CD pipelines to builds, test, and deploy your applications
  • Each project can also have an issue tracker, issue board, and a wiki
  • Used by more than 100,000 organizations, GitLab is the most popular solution to manage Git repositories on-premises
  • Completely free and open source (MIT Expat license)

Hiring

We're hiring developers, support people, and production engineers all the time, please see our jobs page.

Editions

There are two editions of GitLab:

  • GitLab Community Edition (CE) is available freely under the MIT Expat license.
  • GitLab Enterprise Edition (EE) includes extra features that are more useful for organizations with more than 100 users. To use EE and get official support please become a subscriber.

Website

On about.gitlab.com you can find more information about:

Requirements

Please see the requirements documentation for system requirements and more information about the supported operating systems.

Installation

The recommended way to install GitLab is with the Omnibus packages on our package server. Compared to an installation from source, this is faster and less error prone. Just select your operating system, download the respective package (Debian or RPM) and install it using the system's package manager.

There are various other options to install GitLab, please refer to the installation page on the GitLab website for more information.

You can access a new installation with the login root and password 5iveL!fe, after login you are required to set a unique password.

Contributing

GitLab is an open source project and we are very happy to accept community contributions. Please refer to CONTRIBUTING.md for details.

Install a development environment

To work on GitLab itself, we recommend setting up your development environment with the GitLab Development Kit. If you do not use the GitLab Development Kit you need to install and setup all the dependencies yourself, this is a lot of work and error prone. One small thing you also have to do when installing it yourself is to copy the example development unicorn configuration file:

cp config/unicorn.rb.example.development config/unicorn.rb

Instructions on how to start GitLab and how to run the tests can be found in the getting started section of the GitLab Development Kit.

Software stack

GitLab is a Ruby on Rails application that runs on the following software:

  • Ubuntu/Debian/CentOS/RHEL/OpenSUSE
  • Ruby (MRI) 2.3
  • Git 2.8.4+
  • Redis 2.8+
  • PostgreSQL (preferred) or MySQL

For more information please see the architecture documentation.

UX design

Please adhere to the UX Guide when creating designs and implementing code.

Third-party applications

There are a lot of third-party applications integrating with GitLab. These include GUI Git clients, mobile applications and API wrappers for various languages.

GitLab release cycle

For more information about the release process see the release documentation.

Upgrading

For upgrading information please see our update page.

Documentation

All documentation can be found on docs.gitlab.com/ce/.

Getting help

Please see Getting help for GitLab on our website for the many options to get help.

Is it any good?

Yes

Is it awesome?

Thanks for asking this question Joshua. These people seem to like it.