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
c19df237
Commit
c19df237
authored
May 25, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move disable_prepared_statements to Core
We use this method in initializer for Load Balancing
parent
7ce20dfb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
28 deletions
+27
-28
ee/lib/ee/gitlab/database.rb
ee/lib/ee/gitlab/database.rb
+0
-6
ee/spec/lib/ee/gitlab/database_spec.rb
ee/spec/lib/ee/gitlab/database_spec.rb
+0
-22
lib/gitlab/database.rb
lib/gitlab/database.rb
+5
-0
spec/lib/gitlab/database_spec.rb
spec/lib/gitlab/database_spec.rb
+22
-0
No files found.
ee/lib/ee/gitlab/database.rb
View file @
c19df237
...
@@ -17,12 +17,6 @@ module EE
...
@@ -17,12 +17,6 @@ module EE
!
Postgresql
::
ReplicationSlot
.
lag_too_great?
!
Postgresql
::
ReplicationSlot
.
lag_too_great?
end
end
# Disables prepared statements for the current database connection.
def
disable_prepared_statements
config
=
::
Gitlab
::
Database
.
config
.
merge
(
prepared_statements:
false
)
ActiveRecord
::
Base
.
establish_connection
(
config
)
end
def
geo_uncached_queries
(
&
block
)
def
geo_uncached_queries
(
&
block
)
raise
'No block given'
unless
block_given?
raise
'No block given'
unless
block_given?
...
...
ee/spec/lib/ee/gitlab/database_spec.rb
View file @
c19df237
...
@@ -60,28 +60,6 @@ RSpec.describe Gitlab::Database do
...
@@ -60,28 +60,6 @@ RSpec.describe Gitlab::Database do
end
end
end
end
describe
'.disable_prepared_statements'
do
around
do
|
example
|
original_config
=
::
Gitlab
::
Database
.
config
example
.
run
ActiveRecord
::
Base
.
establish_connection
(
original_config
)
end
it
'disables prepared statements'
do
ActiveRecord
::
Base
.
establish_connection
(
::
Gitlab
::
Database
.
config
.
merge
(
prepared_statements:
true
))
expect
(
ActiveRecord
::
Base
.
connection
.
prepared_statements
).
to
eq
(
true
)
expect
(
ActiveRecord
::
Base
).
to
receive
(
:establish_connection
)
.
with
(
a_hash_including
({
'prepared_statements'
=>
false
})).
and_call_original
described_class
.
disable_prepared_statements
expect
(
ActiveRecord
::
Base
.
connection
.
prepared_statements
).
to
eq
(
false
)
end
end
describe
'.geo_uncached_queries'
do
describe
'.geo_uncached_queries'
do
context
'when no block is given'
do
context
'when no block is given'
do
it
'raises error'
do
it
'raises error'
do
...
...
lib/gitlab/database.rb
View file @
c19df237
...
@@ -89,6 +89,11 @@ module Gitlab
...
@@ -89,6 +89,11 @@ module Gitlab
end
end
end
end
# Disables prepared statements for the current database connection.
def
self
.
disable_prepared_statements
ActiveRecord
::
Base
.
establish_connection
(
config
.
merge
(
prepared_statements:
false
))
end
# @deprecated
# @deprecated
def
self
.
postgresql?
def
self
.
postgresql?
adapter_name
.
casecmp
(
'postgresql'
)
==
0
adapter_name
.
casecmp
(
'postgresql'
)
==
0
...
...
spec/lib/gitlab/database_spec.rb
View file @
c19df237
...
@@ -65,6 +65,28 @@ RSpec.describe Gitlab::Database do
...
@@ -65,6 +65,28 @@ RSpec.describe Gitlab::Database do
end
end
end
end
describe
'.disable_prepared_statements'
do
around
do
|
example
|
original_config
=
::
Gitlab
::
Database
.
config
example
.
run
ActiveRecord
::
Base
.
establish_connection
(
original_config
)
end
it
'disables prepared statements'
do
ActiveRecord
::
Base
.
establish_connection
(
::
Gitlab
::
Database
.
config
.
merge
(
prepared_statements:
true
))
expect
(
ActiveRecord
::
Base
.
connection
.
prepared_statements
).
to
eq
(
true
)
expect
(
ActiveRecord
::
Base
).
to
receive
(
:establish_connection
)
.
with
(
a_hash_including
({
'prepared_statements'
=>
false
})).
and_call_original
described_class
.
disable_prepared_statements
expect
(
ActiveRecord
::
Base
.
connection
.
prepared_statements
).
to
eq
(
false
)
end
end
describe
'.postgresql?'
do
describe
'.postgresql?'
do
subject
{
described_class
.
postgresql?
}
subject
{
described_class
.
postgresql?
}
...
...
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