Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
640a4c88
Commit
640a4c88
authored
Oct 03, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use higher size on Gitlab::Redis connection pool on Sidekiq servers
parent
0bbeff3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletion
+46
-1
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/redis.rb
lib/gitlab/redis.rb
+11
-1
spec/lib/gitlab/redis_spec.rb
spec/lib/gitlab/redis_spec.rb
+34
-0
No files found.
CHANGELOG
View file @
640a4c88
...
...
@@ -37,6 +37,7 @@ v 8.13.0 (unreleased)
- Append issue template to existing description !6149 (Joseph Frazier)
- Trending projects now only show public projects and the list of projects is cached for a day
- Revoke button in Applications Settings underlines on hover.
- Use higher size on Gitlab::Redis connection pool on Sidekiq servers
- Add missing values to linter !6276 (Katarzyna Kobierska Ula Budziszewska)
- Fix Long commit messages overflow viewport in file tree
- Revert avoid touching file system on Build#artifacts?
...
...
lib/gitlab/redis.rb
View file @
640a4c88
...
...
@@ -24,10 +24,20 @@ module Gitlab
end
def
with
@pool
||=
ConnectionPool
.
new
{
::
Redis
.
new
(
params
)
}
@pool
||=
ConnectionPool
.
new
(
size:
pool_size
)
{
::
Redis
.
new
(
params
)
}
@pool
.
with
{
|
redis
|
yield
redis
}
end
def
pool_size
if
Sidekiq
.
server?
# the pool will be used in a multi-threaded context
Sidekiq
.
options
[
:concurrency
]
+
5
else
# probably this is a Unicorn process, so single threaded
5
end
end
def
_raw_config
return
@_raw_config
if
defined?
(
@_raw_config
)
...
...
spec/lib/gitlab/redis_spec.rb
View file @
640a4c88
...
...
@@ -88,6 +88,34 @@ describe Gitlab::Redis do
end
end
describe
'.with'
do
before
{
clear_pool
}
after
{
clear_pool
}
context
'when running not on sidekiq workers'
do
before
{
allow
(
Sidekiq
).
to
receive
(
:server?
).
and_return
(
false
)
}
it
'instantiates a connection pool with size 5'
do
expect
(
ConnectionPool
).
to
receive
(
:new
).
with
(
size:
5
).
and_call_original
described_class
.
with
{
|
_redis
|
true
}
end
end
context
'when running on sidekiq workers'
do
before
do
allow
(
Sidekiq
).
to
receive
(
:server?
).
and_return
(
true
)
allow
(
Sidekiq
).
to
receive
(
:options
).
and_return
({
concurrency:
18
})
end
it
'instantiates a connection pool with a size based on the concurrency of the worker'
do
expect
(
ConnectionPool
).
to
receive
(
:new
).
with
(
size:
18
+
5
).
and_call_original
described_class
.
with
{
|
_redis
|
true
}
end
end
end
describe
'#raw_config_hash'
do
it
'returns default redis url when no config file is present'
do
expect
(
subject
).
to
receive
(
:fetch_config
)
{
false
}
...
...
@@ -114,4 +142,10 @@ describe Gitlab::Redis do
rescue
NameError
# raised if @_raw_config was not set; ignore
end
def
clear_pool
described_class
.
remove_instance_variable
(
:@pool
)
rescue
NameError
# raised if @pool was not set; ignore
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment