Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
gitlab-org
gitlab-exporter
Commits
f4fe502e
Commit
f4fe502e
authored
Jul 19, 2017
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try resetting DB connection in case of a PG::UnableToSend exception
parent
f23fb506
Pipeline
#56016
failed with stage
in 57 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
7 deletions
+18
-7
Gemfile.lock
Gemfile.lock
+1
-1
lib/gitlab_monitor/database/base.rb
lib/gitlab_monitor/database/base.rb
+11
-0
lib/gitlab_monitor/database/ci_builds.rb
lib/gitlab_monitor/database/ci_builds.rb
+3
-3
lib/gitlab_monitor/database/row_count.rb
lib/gitlab_monitor/database/row_count.rb
+1
-1
lib/gitlab_monitor/database/tuple_stats.rb
lib/gitlab_monitor/database/tuple_stats.rb
+1
-1
lib/gitlab_monitor/version.rb
lib/gitlab_monitor/version.rb
+1
-1
No files found.
Gemfile.lock
View file @
f4fe502e
PATH
remote: .
specs:
gitlab-monitor (2.
1
.0)
gitlab-monitor (2.
2
.0)
connection_pool (~> 2.2.1)
pg (~> 0.18.4)
quantile (~> 0.2.0)
...
...
lib/gitlab_monitor/database/base.rb
View file @
f4fe502e
...
...
@@ -27,6 +27,17 @@ module GitLab
def
connection_pool
self
.
class
.
connection_pool
[
@connection_string
]
end
def
with_connection_pool
(
&
block
)
connection_pool
.
with
do
|
conn
|
begin
yield
conn
rescue
PG
::
UnableToSend
=>
e
conn
.
reset
raise
e
end
end
end
end
end
end
...
...
lib/gitlab_monitor/database/ci_builds.rb
View file @
f4fe502e
...
...
@@ -178,7 +178,7 @@ module GitLab
end
def
stale_builds
connection_pool
.
with
do
|
conn
|
with_
connection_pool
do
|
conn
|
conn
.
exec
(
STALE_BUILDS_QUERY
)[
0
][
"count"
].
to_i
end
rescue
PG
::
UndefinedTable
,
PG
::
UndefinedColumn
...
...
@@ -221,7 +221,7 @@ module GitLab
end
def
exec_query_with_custom_random_page_cost
(
query
)
connection_pool
.
with
do
|
conn
|
with_
connection_pool
do
|
conn
|
conn
.
transaction
do
|
trans
|
trans
.
exec
(
SET_RANDOM_PAGE_COST
)
trans
.
exec
(
query
)
...
...
@@ -232,7 +232,7 @@ module GitLab
def
mirror_column?
@mirror_column
||=
begin
connection_pool
.
with
do
|
conn
|
with_
connection_pool
do
|
conn
|
conn
.
exec
(
MIRROR_COLUMN_QUERY
)[
0
][
"exists"
]
==
"t"
end
rescue
PG
::
UndefinedColumn
...
...
lib/gitlab_monitor/database/row_count.rb
View file @
f4fe502e
...
...
@@ -30,7 +30,7 @@ module GitLab
private
def
execute
(
query
)
connection_pool
.
with
do
|
conn
|
with_
connection_pool
do
|
conn
|
conn
.
exec
(
construct_query
(
query
))[
0
][
"count"
]
end
rescue
PG
::
UndefinedTable
,
PG
::
UndefinedColumn
...
...
lib/gitlab_monitor/database/tuple_stats.rb
View file @
f4fe502e
...
...
@@ -15,7 +15,7 @@ module GitLab
SQL
def
run
connection_pool
.
with
do
|
conn
|
with_
connection_pool
do
|
conn
|
conn
.
exec
(
QUERY
).
each
.
with_object
({})
do
|
row
,
stats
|
stats
[
row
.
delete
(
"relname"
)]
=
row
end
...
...
lib/gitlab_monitor/version.rb
View file @
f4fe502e
module
GitLab
module
Monitor
VERSION
=
"2.
1
.0"
.
freeze
VERSION
=
"2.
2
.0"
.
freeze
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