Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selfhosted Supavisor Pooler Keeps Restarting #2914

Open
runningwa opened this issue Nov 25, 2024 · 6 comments
Open

Selfhosted Supavisor Pooler Keeps Restarting #2914

runningwa opened this issue Nov 25, 2024 · 6 comments

Comments

@runningwa
Copy link

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
Copy link
Member

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
Copy link

2efPer commented Nov 26, 2024

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

@runningwa
Copy link
Author

@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
Copy link

underworld14 commented Nov 27, 2024

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
Copy link
Member

avallete commented Nov 27, 2024

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

@visyoss
Copy link

visyoss commented Nov 27, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants