Skip to content

Business intelligence made simple

Attempt to reconnect for checks

Andrew Kanefa859601580f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd04ac70..93d99964 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.3.2 [unreleased]
+
+- Attempt to reconnect for checks
+
## 1.3.1
- Fixed migration error
diff --git a/lib/blazer.rb b/lib/blazer.rb
index 14ab9822..25fd8636 100644
--- a/lib/blazer.rb
+++ b/lib/blazer.rb
@@ -74,6 +74,9 @@ module Blazer
Rails.logger.info "[blazer timeout] query=#{check.query.name}"
tries += 1
sleep(10)
+ elsif error.start_with?("PG::ConnectionBad")
+ data_sources[check.query.data_source].reconnect
+ tries += 1
else
break
end
diff --git a/lib/blazer/data_source.rb b/lib/blazer/data_source.rb
index e620628b..39e6f186 100644
--- a/lib/blazer/data_source.rb
+++ b/lib/blazer/data_source.rb
@@ -139,6 +139,10 @@ module Blazer
["MySQL", "Mysql2", "Mysql2Spatial"].include?(adapter_name)
end
+ def reconnect
+ connection_model.establish_connection(settings["url"])
+ end
+
protected
def adapter_name