Skip to content

Commit

Permalink
Merge pull request #248 from supabase/main
Browse files Browse the repository at this point in the history
Prod deploy
  • Loading branch information
abc3 authored Jan 10, 2024
2 parents 49fd649 + e4c0a92 commit 3a724b5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.2
1.1.5
3 changes: 2 additions & 1 deletion lib/supavisor/db_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions lib/supavisor/helpers.ex
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
Expand Down
7 changes: 5 additions & 2 deletions lib/supavisor/tenant_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

[
Expand Down
10 changes: 7 additions & 3 deletions lib/supavisor_web/controllers/tenant_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
2 changes: 1 addition & 1 deletion test/supavisor/db_handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3a724b5

Please sign in to comment.