Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2146d625
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2146d625
编写于
9月 30, 2017
作者:
A
Andrew Newdigate
提交者:
Robert Speicher
9月 30, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add environment variable to bypass n+1
上级
0781e956
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
2 deletion
+32
-2
doc/development/gitaly.md
doc/development/gitaly.md
+31
-1
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+1
-1
未找到文件。
doc/development/gitaly.md
浏览文件 @
2146d625
...
...
@@ -12,6 +12,7 @@ status of the migration.
Gitaly makes heavy use of
[
feature flags
](
feature_flags.md
)
.
Each Rugged-to-Gitaly migration goes through a
[
series of phases
](
https://gitlab.com/gitlab-org/gitaly/blob/master/doc/MIGRATION_PROCESS.md
)
:
*
**Opt-In**
: by default the Rugged implementation is used.
*
Production instances can choose to enable the Gitaly endpoint by enabling the feature flag.
*
For testing purposes, you may wish to enable all feature flags by default. This can be done by exporting the following
...
...
@@ -19,7 +20,7 @@ Each Rugged-to-Gitaly migration goes through a [series of phases](https://gitlab
*
On developer instances (ie, when
`Rails.env.development?`
is true), the Gitaly endpoint
is enabled by default, but can be _disabled_ using feature flags.
*
**Opt-Out**
: by default, the Gitaly endpoint is used, but the feature can be explicitly disabled using the feature flag.
*
**Madatory**
: The migration is complete and cannot be disabled. The old codepath is removed.
*
**Ma
n
datory**
: The migration is complete and cannot be disabled. The old codepath is removed.
### Enabling and Disabling Feature
...
...
@@ -49,6 +50,35 @@ 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
](
https://gitlab.com/groups/gl-gitaly/group_members
)
for assistance.
Once the source has been found, wrap it in an
`allow_n_plus_1_calls`
block, as follows:
```
ruby
# n+1: link to n+1 issue
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
# original code
commits
.
each
{
|
commit
|
...
}
end
```
Once the code is wrapped in this block, this code-path will be excluded from n+1 detection.
---
[
Return to Development documentation
](
README.md
)
lib/gitlab/gitaly_client.rb
浏览文件 @
2146d625
...
...
@@ -151,7 +151,7 @@ module Gitlab
actual_call_count
=
increment_call_count
(
"gitaly_
#{
call_site
}
_actual"
)
# Do no enforce limits in production
return
if
Rails
.
env
.
production?
return
if
Rails
.
env
.
production?
||
ENV
[
"GITALY_DISABLE_REQUEST_LIMITS"
]
# Check if this call is nested within a allow_n_plus_1_calls
# block and skip check if it is
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录