From 7738e80e92e388f0c91089384a443fda75f1d177 Mon Sep 17 00:00:00 2001 From: Kayla Brady <31781298+KaylaBrady@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:48:36 -0400 Subject: [PATCH] feat(Skate.Warmup): More logging for failed queries (#2157) * feat(Skate.Warmup): More logging for failed queries * chore(Skate.Warmup): update retry configuration --- config/config.exs | 4 ++-- lib/skate/warm_up.ex | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/config/config.exs b/config/config.exs index 95ab366cb..719e05474 100644 --- a/config/config.exs +++ b/config/config.exs @@ -114,8 +114,8 @@ config :skate, Skate.Repo, config :skate, Skate.WarmUp, minimum_percent_queries_to_succeed: 0.6, - max_attempts: 5, - seconds_between_attempts: 3 + max_attempts: 20, + seconds_between_attempts: 1 config :laboratory, features: [ diff --git a/lib/skate/warm_up.ex b/lib/skate/warm_up.ex index 5f63f4907..1150e418c 100644 --- a/lib/skate/warm_up.ex +++ b/lib/skate/warm_up.ex @@ -16,8 +16,8 @@ defmodule Skate.WarmUp do seconds_between_attempts = warmup_config[:seconds_between_attempts] || 0 warm_up_check_fn = - Application.get_env(:skate, :warm_up_test_fn, fn _index, _attemptgit -> - Skate.Repo.query("SELECT 1", []) + Application.get_env(:skate, :warm_up_test_fn, fn index, attempt -> + attempt_query(index, attempt) end) case check_connections_warmed_up(%{ @@ -39,6 +39,20 @@ defmodule Skate.WarmUp do end end + defp attempt_query(index, attempt) do + case Skate.Repo.query("SELECT 1", []) do + {:ok, result} -> + {:ok, result} + + {:error, error} -> + Logger.warn( + "#{__MODULE__} warmup query failed. attempt=#{attempt} query_number=#{index} reason=#{inspect(error)}" + ) + + {:error, error} + end + end + defp check_connections_warmed_up( %{ pool_size: pool_size,