Parcourir la source

Try 3 times on timeout errors

Andrew Kane il y a 9 ans
Parent
commit
d1f394d69b
1 fichiers modifiés avec 8 ajouts et 1 suppressions
  1. 8 1
      lib/blazer.rb

+ 8 - 1
lib/blazer.rb

@@ -72,7 +72,14 @@ module Blazer
 
   def self.run_checks
     Blazer::Check.includes(:blazer_query).find_each do |check|
-      rows, error = run_statement(check.blazer_query.statement)
+      rows = nil
+      error = nil
+      tries = 0
+      # try 3 times on timeout errors
+      begin
+        rows, error = run_statement(check.blazer_query.statement)
+        tries += 1
+      end while error && error.include?("canceling statement due to statement timeout") && tries < 3
       check.update_state(rows, error)
     end
   end