GitLab Documentation

GitLab Developers Guide to Working with Gitaly

Gitaly is a high-level Git RPC service used by GitLab CE/EE, Workhorse and GitLab-Shell. All Rugged operations in GitLab CE/EE are currently being phased out to be replaced by Gitaly API calls.

Visit the Gitaly Migration Board for current status of the migration.

Feature Flags

Gitaly makes heavy use of feature flags.

Each Rugged-to-Gitaly migration goes through a series of phases:

Enabling and Disabling Feature

In the Rails console, type:


Where gitaly_feature_name is the name of the Gitaly feature. This can be determined by finding the appropriate gitaly_migrate code block, for example:

gitaly_migrate(:tag_names) do

Since Gitaly features are always prefixed with gitaly_, the name of the feature flag in this case would be gitaly_tag_names.

If your test-suite is failing with Gitaly issues, as a first step, try running:

rm -rf tmp/tests/gitaly

TooManyInvocationsError errors

During development and testing, you may experience Gitlab::GitalyClient::TooManyInvocationsError failures. The GitalyClient will attempt to block against potential n+1 issues by raising this error when Gitaly is called more than 30 times in a single Rails request or Sidekiq execution.

As a temporary measure, export GITALY_DISABLE_REQUEST_LIMITS=1 to suppress the error. This will disable the n+1 detection in your development environment.

Please raise an issue in the GitLab CE or EE repositories to report the issue. Include the labels ~Gitaly ~performance ~"technical debt". Please ensure that the issue contains the full stack trace and error message of the TooManyInvocationsError. Also include any known failing tests if possible.

Isolate the source of the n+1 problem. This will normally be a loop that results in Gitaly being called for each element in an array. If you are unable to isolate the problem, please contact a member of the Gitaly Team for assistance.

Once the source has been found, wrap it in an allow_n_plus_1_calls block, as follows:

# n+1: link to n+1 issue
Gitlab::GitalyClient.allow_n_plus_1_calls do
  # original code
  commits.each { |commit| ... }

Once the code is wrapped in this block, this code-path will be excluded from n+1 detection.

Return to Development documentation