supabase / supavisor

A cloud-native, multi-tenant Postgres connection pooler.
https://supabase.github.io/supavisor/
Apache License 2.0
1.73k stars 55 forks source link

Pooler container error on start: `Tenant or user not found` #364

Closed bombillazo closed 1 month ago

bombillazo commented 3 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Run supabase start
  2. pooler image fails
2024-06-18 14:22:00 Setting RLIMIT_NOFILE to 100000
2024-06-18 14:22:00 18:22:00.981 [info] Migrations already up
2024-06-18 14:22:01 18:22:01.293 [notice] [description: 'Partisan node name generated and configured', disterl_enabled: false, name: :"a7f8e05c-2d9f-11ef-9111-b453f023eab8@6f09855866bf"]
2024-06-18 14:22:01 18:22:01.303 [notice] [addr: {0, 0, 0, 0, 0, 0, 0, 1}, description: 'Resolved IP address for host', family: :inet6, host: '6f09855866bf']
2024-06-18 14:22:01 18:22:01.314 [info] [description: 'Not using container orchestration; disabling.']
2024-06-18 14:22:01 18:22:01.385 [info] [description: 'Starting Partisan listener', listen_addrs: [%{ip: {127, 0, 0, 1}, port: 20100}]]
2024-06-18 14:22:01 18:22:01.800 region=local [info] Elixir.Supavisor.SignalHandler is being initialized...
2024-06-18 14:22:01 18:22:01.811 region=local [warning] Proxy started transaction on port 6543, result: {:ok, #PID<0.396.0>}
2024-06-18 14:22:01 18:22:01.811 region=local [warning] Proxy started session on port 5432, result: {:ok, #PID<0.499.0>}
2024-06-18 14:22:01 18:22:01.814 region=local [notice] SYN[nonode@nohost] Adding node to scope <tenants>
2024-06-18 14:22:01 18:22:01.817 region=local [notice] SYN[nonode@nohost] Creating tables for scope <tenants>
2024-06-18 14:22:01 18:22:01.820 region=local [notice] SYN[nonode@nohost|registry<tenants>] Discovering the cluster
2024-06-18 14:22:01 18:22:01.821 region=local [notice] SYN[nonode@nohost|pg<tenants>] Discovering the cluster
2024-06-18 14:22:01 18:22:01.977 region=local [info] Running SupavisorWeb.Endpoint with cowboy 2.10.0 at 0.0.0.0:4000 (http)
2024-06-18 14:22:01 18:22:01.979 region=local [info] Access SupavisorWeb.Endpoint at http://localhost:4000
2024-06-18 14:22:02 ** (MatchError) no match of right hand side value: {:error, #Ecto.Changeset<action: :insert, changes: %{allow_list: ["0.0.0.0/0", "::/0"], auth_query: "SELECT * FROM pgbouncer.get_auth($1)", client_heartbeat_interval: 60, client_idle_timeout: 0, db_database: "postgres", db_host: "supabase_db_app", db_port: 5432, default_max_clients: 1000, default_parameter_status: %{"server_version" => "15.1 (Ubuntu 15.1-1.pgdg20.04+1)"}, default_pool_size: 20, enforce_ssl: false, external_id: "pooler-dev", ip_version: :auto, require_user: false, upstream_ssl: false, users: [#Ecto.Changeset<action: :insert, changes: %{db_password: "postgres", db_user: "pgbouncer", db_user_alias: "pgbouncer", is_manager: true, mode_type: :transaction, pool_size: 20}, errors: [], data: #Supavisor.Tenants.User<>, valid?: true>]}, errors: [external_id: {"has already been taken", [constraint: :unique, constraint_name: "tenants_external_id_index"]}], data: #Supavisor.Tenants.Tenant<>, valid?: false>}
2024-06-18 14:22:02     (stdlib 4.3) erl_eval.erl:496: :erl_eval.expr/6
2024-06-18 14:22:02     nofile:28: (file)
2024-06-18 14:22:02     (elixir 1.14.3) lib/code.ex:425: Code.validated_eval_string/3
2024-06-18 14:22:02 [os_mon] cpu supervisor port (cpu_sup): Erlang has closed
2024-06-18 14:22:02 [os_mon] memory supervisor port (memsup): Erlang has closed

Sometimes after multiple stack rebuilds, I get this when I try to connect to the database:

2024-06-19 10:58:07 14:58:07.673 region=local [error] ClientHandler: User not found: "Either external_id or sni_hostname must be provided" {:single, "postgres", nil}
2024-06-19 10:58:07 14:58:07.673 region=local [warning] client_join is called with a mismatched id: nil
2024-06-19 10:58:07 14:58:07.674 region=local [warning] ClientHandler: socket closed with reason {:shutdown, :user_not_found}

Expected behavior All stack including pooler start up succesfully

System information

bombillazo commented 1 month ago

This was fixed in one of the recent CLI releases