supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.09k stars 212 forks source link

Selfhosted Supavisor Pooler Keeps Restarting #2914

Closed runningwa closed 22 hours ago

runningwa commented 3 days ago

Describe the bug The Supavisor pooler in my self-hosted Supabase setup keeps restarting . I check log ,it shows this error messages:

    Setting RLIMIT_NOFILE to 100000
    10:29:48.672 [error] Could not create schema migrations table. This error usually happens due to the following:

  * The database does not exist
  * The "schema_migrations" table, which Ecto uses for managing
    migrations, was defined by another library
  * There is a deadlock while migrating (such as using concurrent
    indexes with a migration_lock)

  To fix the first issue, run "mix ecto.create" for the desired MIX_ENV.

To address the second, you can run "mix ecto.drop" followed by
"mix ecto.create", both for the desired MIX_ENV. Alternatively you may
configure Ecto to use another table and/or repository for managing
migrations:

config :supavisor, Supavisor.Repo,
  migration_source: "some_other_table_for_schema_migrations",
  migration_repo: AnotherRepoForSchemaMigrations

The full error report is shown below.

(Postgrex.Error) ERROR 42501 (insufficient_privilege) permission denied for schema _supavisor
    (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1
    (elixir 1.14.3) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1154: Ecto.Adapters.SQL.execute_ddl/4
    (ecto_sql 3.10.2) lib/ecto/migrator.ex:756: Ecto.Migrator.verbose_schema_migration/3
    (ecto_sql 3.10.2) lib/ecto/migrator.ex:564: Ecto.Migrator.lock_for_migrations/4
    (ecto_sql 3.10.2) lib/ecto/migrator.ex:433: Ecto.Migrator.run/4
    (ecto_sql 3.10.2) lib/ecto/migrator.ex:170: Ecto.Migrator.with_repo/3
    nofile:1: (file)

To Reproduce Steps to reproduce the behavior:

  1. Go through the selfhost setup from Supabase.

Expected behavior The Supavisor pooler should start and I have no idea about this problem

Screenshots image

Additional context Any help or guidance on troubleshooting this error further would be appreciated. Thank you!

avallete commented 3 days ago

Hey @runningwa

The _supabase database is a new addition to separate the internal Supabase tables (like analytics) from user data. Did you upgrade your self-hosted stack recently ?

If you’re setting up fresh, it works out of the box. But for upgrades, some manual steps are needed since the database is already initialized. This comment explains the steps.

We know the upgrade process isn’t ideal right now, and we’re looking into ways to make it smoother for self-hosted users—thanks for pointing it out! Let me know if you run into any issues, and I’ll do my best to help.

2efPer commented 2 days ago

I couldn't start pooler in a fresh new environment either.

runningwa commented 2 days ago

@avallete Thanks for your reply. I tried a fresh installation, but still had this problem. The supabase-pooler container kept restarting. The database should be brand new, with no old data. The logs also had the above problem. I used the latest version of the file. My operating system is Ubuntu 24.0.4, and Docker version is 24.0.7.

underworld14 commented 2 days ago

I got the error logs for pooler service :

se-pooler  |   * The database does not exist
supabase-pooler  |   * The "schema_migrations" table, which Ecto uses for managing
supabase-pooler  |     migrations, was defined by another library
supabase-pooler  |   * There is a deadlock while migrating (such as using concurrent
supabase-pooler  |     indexes with a migration_lock)
supabase-pooler  | 
supabase-pooler  | To fix the first issue, run "mix ecto.create" for the desired MIX_ENV.
supabase-pooler  | 
supabase-pooler  | To address the second, you can run "mix ecto.drop" followed by
supabase-pooler  | "mix ecto.create", both for the desired MIX_ENV. Alternatively you may
supabase-pooler  | configure Ecto to use another table and/or repository for managing
supabase-pooler  | migrations:
supabase-pooler  | 
supabase-pooler  |     config :supavisor, Supavisor.Repo,
supabase-pooler  |       migration_source: "some_other_table_for_schema_migrations",
supabase-pooler  |       migration_repo: AnotherRepoForSchemaMigrations
supabase-pooler  | 
supabase-pooler  | The full error report is shown below.
supabase-pooler  | 
supabase-pooler  | ** (Postgrex.Error) ERROR 42501 (insufficient_privilege) permission denied for schema _supavisor
supabase-pooler  |     (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1
supabase-pooler  |     (elixir 1.14.3) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
supabase-pooler  |     (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1154: Ecto.Adapters.SQL.execute_ddl/4
supabase-pooler  |     (ecto_sql 3.10.2) lib/ecto/migrator.ex:756: Ecto.Migrator.verbose_schema_migration/3
supabase-pooler  |     (ecto_sql 3.10.2) lib/ecto/migrator.ex:564: Ecto.Migrator.lock_for_migrations/4
supabase-pooler  |     (ecto_sql 3.10.2) lib/ecto/migrator.ex:433: Ecto.Migrator.run/4
supabase-pooler  |     (ecto_sql 3.10.2) lib/ecto/migrator.ex:170: Ecto.Migrator.with_repo/3
supabase-pooler  |     nofile:1: (file)
avallete commented 1 day ago

Hey there, it seems that the issue is related to the role to use after a PG image upgrade. The pooler should connect as "supabase_admin". Like so:

 DATABASE_URL=ecto://supabase_admin:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/_supabase

A fix is on its way here: https://github.com/supabase/supabase/pull/30674

visyoss commented 1 day ago

Hey there, it seems that the issue is related to the role to use after a PG image upgrade. The pooler should connect as "supabase_admin". Like so:

DATABASE_URL=ecto://supabase_admin:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/_supabase

A fix is on its way here: supabase/supabase#30674

This works tysm!

runningwa commented 22 hours ago

Hey there, it seems that the issue is related to the role to use after a PG image upgrade. The pooler should connect as "supabase_admin". Like so:

DATABASE_URL=ecto://supabase_admin:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/_supabase

A fix is on its way here: supabase/supabase#30674

Edit docker-compose.yaml .This works tysm!

runningwa commented 22 hours ago

Edit docker-compose.yaml Modify the configuration of supabase-pooler: DATABASE_URL=ecto://supabase_admin:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/_supabase