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
08fcb237
Commit
08fcb237
authored
Aug 23, 2019
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CE port: allow SRV records in DB service discovery
parent
e12f7fe0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
doc/administration/database_load_balancing.md
doc/administration/database_load_balancing.md
+6
-1
lib/gitlab/database.rb
lib/gitlab/database.rb
+2
-1
spec/lib/gitlab/database_spec.rb
spec/lib/gitlab/database_spec.rb
+11
-0
No files found.
doc/administration/database_load_balancing.md
View file @
08fcb237
...
...
@@ -122,6 +122,7 @@ production:
discover
:
nameserver
:
localhost
record
:
secondary.postgresql.service.consul
record_type
:
A
port
:
8600
interval
:
60
disconnect_timeout
:
120
...
...
@@ -137,12 +138,16 @@ The following options can be set:
| Option | Description | Default |
|----------------------|---------------------------------------------------------------------------------------------------|-----------|
|
`nameserver`
| The nameserver to use for looking up the DNS record. | localhost |
|
`record`
| The A record to look up. This option is required for service discovery to work. | |
|
`record`
| The record to look up. This option is required for service discovery to work. | |
|
`record_type`
| Optional record type to look up, this can be either A or SRV (since GitLab 12.3) | A |
|
`port`
| The port of the nameserver. | 8600 |
|
`interval`
| The minimum time in seconds between checking the DNS record. | 60 |
|
`disconnect_timeout`
| The time in seconds after which an old connection is closed, after the list of hosts was updated. | 120 |
|
`use_tcp`
| Lookup DNS resources using TCP instead of UDP | false |
If
`record_type`
is set to
`SRV`
, GitLab will continue to use a round-robin algorithm
and will ignore the
`weight`
and
`priority`
in the record.
The
`interval`
value specifies the _minimum_ time between checks. If the A
record has a TTL greater than this value, then service discovery will honor said
TTL. For example, if the TTL of the A record is 90 seconds, then service
...
...
lib/gitlab/database.rb
View file @
08fcb237
...
...
@@ -195,13 +195,14 @@ module Gitlab
# pool_size - The size of the DB pool.
# host - An optional host name to use instead of the default one.
def
self
.
create_connection_pool
(
pool_size
,
host
=
nil
)
def
self
.
create_connection_pool
(
pool_size
,
host
=
nil
,
port
=
nil
)
# See activerecord-4.2.7.1/lib/active_record/connection_adapters/connection_specification.rb
env
=
Rails
.
env
original_config
=
ActiveRecord
::
Base
.
configurations
env_config
=
original_config
[
env
].
merge
(
'pool'
=>
pool_size
)
env_config
[
'host'
]
=
host
if
host
env_config
[
'port'
]
=
port
if
port
config
=
original_config
.
merge
(
env
=>
env_config
)
...
...
spec/lib/gitlab/database_spec.rb
View file @
08fcb237
...
...
@@ -347,6 +347,17 @@ describe Gitlab::Database do
pool
.
disconnect!
end
end
it
'allows setting of a custom hostname and port'
do
pool
=
described_class
.
create_connection_pool
(
5
,
'127.0.0.1'
,
5432
)
begin
expect
(
pool
.
spec
.
config
[
:host
]).
to
eq
(
'127.0.0.1'
)
expect
(
pool
.
spec
.
config
[
:port
]).
to
eq
(
5432
)
ensure
pool
.
disconnect!
end
end
end
describe
'.cached_column_exists?'
do
...
...
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