Skip to content

Commit

Permalink
fix cluster starting
Browse files Browse the repository at this point in the history
  • Loading branch information
abc3 committed Nov 15, 2023
1 parent e796512 commit ef2221a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/supavisor/db_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ defmodule Supavisor.DbHandler do
end

other ->
Logger.error("Connection failed #{inspect(other)}")
Logger.error(
"Connection failed #{inspect(other)} to #{inspect(auth.host)}:#{inspect(auth.port)}"
)

reconnect_callback
end
end
Expand Down Expand Up @@ -334,6 +337,13 @@ defmodule Supavisor.DbHandler do
:keep_state_and_data
end

@impl true
def terminate(:shutdown, _state, _data), do: :ok

def terminate(reason, state, _data) do
Logger.error("Terminating with reason #{inspect(reason)} when state was #{inspect(state)}")
end

@spec try_ssl_handshake(S.tcp_sock(), map) :: {:ok, S.sock()} | {:error, term()}
defp try_ssl_handshake(sock, %{upstream_ssl: true} = auth) do
case sock_send(sock, Server.ssl_request()) do
Expand Down
4 changes: 2 additions & 2 deletions lib/supavisor/tenants.ex
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ defmodule Supavisor.Tenants do

query =
from(ct in ClusterTenants,
where: ct.cluster_alias == ^cluster_alias,
where: ct.cluster_alias == ^cluster_alias and ct.active == true,
preload: [tenant: ^tenant]
)

Expand Down Expand Up @@ -353,7 +353,7 @@ defmodule Supavisor.Tenants do
on: u.tenant_external_id == t.external_id,
where:
(u.db_user_alias == ^user and t.require_user == true) or
t.require_user == false,
(t.require_user == false and u.is_manager == true),
select: {u, t}
)
|> where(^with_tenant(external_id, sni_hostname))
Expand Down

0 comments on commit ef2221a

Please sign in to comment.