diff --git a/VERSION b/VERSION index 45a1b3f4..e25d8d9f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.2 +1.1.5 diff --git a/lib/supavisor/db_handler.ex b/lib/supavisor/db_handler.ex index b7c17c99..f318e501 100644 --- a/lib/supavisor/db_handler.ex +++ b/lib/supavisor/db_handler.ex @@ -27,7 +27,8 @@ defmodule Supavisor.DbHandler do @impl true def init(args) do Process.flag(:trap_exit, true) - Logger.metadata(project: args.tenant, user: args.user, mode: args.mode) + {_, tenant} = args.tenant + Logger.metadata(project: tenant, user: args.user, mode: args.mode) data = %{ id: args.id, diff --git a/lib/supavisor/helpers.ex b/lib/supavisor/helpers.ex index e33b556a..631ef775 100644 --- a/lib/supavisor/helpers.ex +++ b/lib/supavisor/helpers.ex @@ -1,7 +1,7 @@ defmodule Supavisor.Helpers do @moduledoc false - @spec check_creds_get_ver(map) :: {:ok, String.t()} | {:error, String.t()} + @spec check_creds_get_ver(map) :: {:ok, String.t() | nil} | {:error, String.t()} def check_creds_get_ver(%{"require_user" => false} = params) do cond do @@ -16,10 +16,12 @@ defmodule Supavisor.Helpers do end end - def check_creds_get_ver(params) do + def check_creds_get_ver(%{"users" => _} = params) do do_check_creds_get_ver(params) end + def check_creds_get_ver(_), do: {:ok, nil} + def do_check_creds_get_ver(params) do Enum.reduce_while(params["users"], {nil, nil}, fn user, _ -> upstream_ssl? = !!params["upstream_ssl"] diff --git a/lib/supavisor/tenant_supervisor.ex b/lib/supavisor/tenant_supervisor.ex index 32fd2424..7a57cc2b 100644 --- a/lib/supavisor/tenant_supervisor.ex +++ b/lib/supavisor/tenant_supervisor.ex @@ -49,8 +49,11 @@ defmodule Supavisor.TenantSupervisor do defp pool_spec(id, args) do {size, overflow} = case args.mode do - :session -> {1, args.pool_size} - :transaction -> {args.pool_size, 0} + :session -> + {1, args.pool_size} + + :transaction -> + if args.pool_size < 10, do: {args.pool_size, 0}, else: {10, args.pool_size - 10} end [ diff --git a/lib/supavisor_web/controllers/tenant_controller.ex b/lib/supavisor_web/controllers/tenant_controller.ex index 88e93b7c..4acffdd0 100644 --- a/lib/supavisor_web/controllers/tenant_controller.ex +++ b/lib/supavisor_web/controllers/tenant_controller.ex @@ -128,9 +128,13 @@ defmodule SupavisorWeb.TenantController do {:ok, pg_version} -> params = - Map.put(params, "default_parameter_status", %{ - "server_version" => pg_version - }) + if pg_version do + Map.put(params, "default_parameter_status", %{ + "server_version" => pg_version + }) + else + params + end case Tenants.get_tenant_by_external_id(id) do nil -> diff --git a/test/supavisor/db_handler_test.exs b/test/supavisor/db_handler_test.exs index 12819cca..dc18ae2d 100644 --- a/test/supavisor/db_handler_test.exs +++ b/test/supavisor/db_handler_test.exs @@ -8,7 +8,7 @@ defmodule Supavisor.DbHandlerTest do args = %{ id: {"a", "b"}, auth: %{}, - tenant: "test_tenant", + tenant: {:single, "test_tenant"}, user_alias: "test_user_alias", user: "user", mode: :transaction,