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
d6383646
Commit
d6383646
authored
Dec 03, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
b52493bf
bd145786
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
7 additions
and
64 deletions
+7
-64
app/models/concerns/reactive_caching.rb
app/models/concerns/reactive_caching.rb
+2
-1
doc/development/shell_scripting_guide/index.md
doc/development/shell_scripting_guide/index.md
+1
-1
doc/development/sidekiq_style_guide.md
doc/development/sidekiq_style_guide.md
+1
-1
ee/config/feature_flags/development/query_cache_for_load_balancing.yml
...ture_flags/development/query_cache_for_load_balancing.yml
+0
-8
ee/lib/gitlab/database/load_balancing/host.rb
ee/lib/gitlab/database/load_balancing/host.rb
+1
-1
ee/lib/gitlab/database/load_balancing/load_balancer.rb
ee/lib/gitlab/database/load_balancing/load_balancer.rb
+1
-26
ee/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
.../lib/gitlab/database/load_balancing/load_balancer_spec.rb
+1
-26
No files found.
app/models/concerns/reactive_caching.rb
View file @
d6383646
# frozen_string_literal: true
# The usage of the ReactiveCaching module is documented here:
# https://docs.gitlab.com/ee/development/reactive_caching.md
# https://docs.gitlab.com/ee/development/reactive_caching.html
#
module
ReactiveCaching
extend
ActiveSupport
::
Concern
...
...
doc/development/shell_scripting_guide/index.md
View file @
d6383646
...
...
@@ -92,7 +92,7 @@ use this job:
```
yaml
shfmt
:
image
:
mvdan/shfmt:v3.
1
.0-alpine
image
:
mvdan/shfmt:v3.
2
.0-alpine
stage
:
test
before_script
:
-
shfmt -version
...
...
doc/development/sidekiq_style_guide.md
View file @
d6383646
...
...
@@ -472,7 +472,7 @@ A job cannot be both high urgency and have external dependencies.
Workers that are constrained by CPU or memory resource limitations should be
annotated with the
`worker_resource_boundary`
method.
Most workers tend to spend most of their time blocked, wait on network responses
Most workers tend to spend most of their time blocked, wait
ing
on network responses
from other services such as Redis, PostgreSQL, and Gitaly. Since Sidekiq is a
multi-threaded environment, these jobs can be scheduled with high concurrency.
...
...
ee/config/feature_flags/development/query_cache_for_load_balancing.yml
deleted
100644 → 0
View file @
b52493bf
---
name
:
query_cache_for_load_balancing
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46765
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/276203
milestone
:
'
13.7'
type
:
development
group
:
group::memory
default_enabled
:
false
ee/lib/gitlab/database/load_balancing/host.rb
View file @
d6383646
...
...
@@ -7,7 +7,7 @@ module Gitlab
class
Host
attr_reader
:pool
,
:last_checked_at
,
:intervals
,
:load_balancer
,
:host
,
:port
delegate
:connection
,
:release_connection
,
:enable_query_cache!
,
:disable_query_cache!
,
to: :pool
delegate
:connection
,
:release_connection
,
to: :pool
CONNECTION_ERRORS
=
if
defined?
(
PG
)
...
...
ee/lib/gitlab/database/load_balancing/load_balancer.rb
View file @
d6383646
...
...
@@ -12,7 +12,6 @@ module Gitlab
# always returns a connection to the primary.
class
LoadBalancer
CACHE_KEY
=
:gitlab_load_balancer_host
ENSURE_CACHING_KEY
=
'ensure_caching'
attr_reader
:host_list
...
...
@@ -29,8 +28,6 @@ module Gitlab
conflict_retried
=
0
while
host
ensure_caching!
begin
return
yield
host
.
connection
rescue
=>
error
...
...
@@ -98,12 +95,7 @@ module Gitlab
# Releases the host and connection for the current thread.
def
release_host
if
host
=
RequestStore
[
CACHE_KEY
]
host
.
disable_query_cache!
host
.
release_connection
end
RequestStore
.
delete
(
ENSURE_CACHING_KEY
)
RequestStore
[
CACHE_KEY
]
&
.
release_connection
RequestStore
.
delete
(
CACHE_KEY
)
end
...
...
@@ -177,23 +169,6 @@ module Gitlab
error
.
is_a?
(
PG
::
TRSerializationFailure
)
end
end
private
# TODO:
# Move enable_query_cache! to ConnectionPool (https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/database.rb#L223)
# when the feature flag is removed in https://gitlab.com/gitlab-org/gitlab/-/issues/276203.
def
ensure_caching!
# Feature (Flipper gem) reads the data from the database, and it would cause the infinite loop here.
# We need to ensure that the code below is executed only once, until the feature flag is removed.
return
if
RequestStore
[
ENSURE_CACHING_KEY
]
RequestStore
[
ENSURE_CACHING_KEY
]
=
true
if
Feature
.
enabled?
(
:query_cache_for_load_balancing
)
host
.
enable_query_cache!
end
end
end
end
end
...
...
ee/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
View file @
d6383646
...
...
@@ -12,7 +12,6 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer do
after
do
RequestStore
.
delete
(
described_class
::
CACHE_KEY
)
RequestStore
.
delete
(
described_class
::
ENSURE_CACHING_KEY
)
end
def
raise_and_wrap
(
wrapper
,
original
)
...
...
@@ -53,28 +52,8 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer do
allow
(
lb
).
to
receive
(
:host
).
and_return
(
host
)
expect
(
host
).
to
receive
(
:connection
).
and_return
(
connection
)
expect
(
host
).
to
receive
(
:enable_query_cache!
).
once
expect
{
|
b
|
lb
.
read
(
&
b
)
}.
to
yield_with_args
(
connection
)
expect
(
RequestStore
[
described_class
::
ENSURE_CACHING_KEY
]).
to
be
true
end
context
'when :query_cache_for_load_balancing feature flag is disabled'
do
before
do
stub_feature_flags
(
query_cache_for_load_balancing:
false
)
end
it
'yields a connection for a read without enabling query cache'
do
connection
=
double
(
:connection
)
host
=
double
(
:host
)
allow
(
lb
).
to
receive
(
:host
).
and_return
(
host
)
expect
(
host
).
to
receive
(
:connection
).
and_return
(
connection
)
expect
(
host
).
not_to
receive
(
:enable_query_cache!
)
expect
{
|
b
|
lb
.
read
(
&
b
)
}.
to
yield_with_args
(
connection
)
end
end
it
'marks hosts that are offline'
do
...
...
@@ -163,14 +142,10 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer do
describe
'#release_host'
do
it
'releases the host and its connection'
do
host
=
lb
.
host
expect
(
host
).
to
receive
(
:disable_query_cache!
)
lb
.
host
lb
.
release_host
expect
(
RequestStore
[
described_class
::
CACHE_KEY
]).
to
be_nil
expect
(
RequestStore
[
described_class
::
ENSURE_CACHING_KEY
]).
to
be_nil
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