Vonng / pigsty

Battery-Included PostgreSQL Distro as a Free RDS Alternative
https://pigsty.io
GNU Affero General Public License v3.0
3.01k stars 242 forks source link

Run supabase got issue `unrecognized configuration parameter "pgsodium.enable_event_trigger"` in supabase-analytics. #350

Closed Michael2008S closed 5 months ago

Michael2008S commented 7 months ago

docoker compose 执行与报错信息:

[12-07 17:59:30] michael@rocky9Pigsty:~/pigsty/app/supabase 
$ docker compose up
[+] Running 3/3
 ✔ Container supabase-imgproxy   Running                                                                                                                                                                    0.0s 
 ✔ Container supabase-analytics  Running                                                                                                                                                                    0.0s 
 ✔ Container supabase-kong       Recreated                                                                                                                                                                  0.1s 
Attaching to realtime-dev.supabase-realtime, supabase-analytics, supabase-auth, supabase-edge-functions, supabase-imgproxy, supabase-kong, supabase-meta, supabase-rest, supabase-storage, supabase-studio
supabase-imgproxy               | INFO    [2023-12-07T09:59:34Z] Started /health  request_id=ZirfLaCRnGCkTnssnaEIx method=GET client_ip=127.0.0.1
supabase-imgproxy               | INFO    [2023-12-07T09:59:34Z] Completed in 106.06µs /health  request_id=ZirfLaCRnGCkTnssnaEIx method=GET status=200 client_ip=127.0.0.1
supabase-analytics              | Kernel pid terminated (application_controller) ({application_start_failure,logflare,{{shutdown,{failed_to_start_child,'Elixir.Logflare.SystemMetricsSup',{shutdown,{failed_to_start_child,'Elixir.Logflare.SystemMetrics.AllLogsLogged',{#{'__exception__' => true,'__struct__' => 'Elixir.Postgrex.Error',connection_id => 3059664,message => nil,postgres => #{code => undefined_table,file => <<"parse_relation.c">>,line => <<"1392">>,message => <<"relation \"system_metrics\" does not exist">>,pg_code => <<"42P01">>,position => <<"89">>,routine => <<"parserOpenTable">>,severity => <<"ERROR">>,unknown => <<"ERROR">>},query => <<"SELECT s0.\"id\", s0.\"all_logs_logged\", s0.\"node\", s0.\"inserted_at\", s0.\"updated_at\" FROM \"system_metrics\" AS s0 WHERE (s0.\"node\" = $1)">>},[{'Elixir.Ecto.Adapters.SQL',raise_sql_call_error,1,[{file,"lib/ecto/adapters/sql.ex"},{line,913},{error_info,#{module => 'Elixir.Exception'}}]},{'Elixir.Ecto.Adapters.SQL',execute,6,[{file,"lib/ecto/adapters/sql.ex"},{line,828}]},{'Elixir.Ecto.Re
supabase-analytics              | 
supabase-analytics              | Crash dump is being written to: erl_crash.dump...done
supabase-analytics              | sh: 09:59:19.142: not found
supabase-imgproxy               | INFO    [2023-12-07T09:59:41Z] Started /health  request_id=ZbASup8m_N4U7ky9lHNBc method=GET client_ip=127.0.0.1
supabase-imgproxy               | INFO    [2023-12-07T09:59:41Z] Completed in 759.949µs /health  request_id=ZbASup8m_N4U7ky9lHNBc method=GET status=200 client_ip=127.0.0.1
supabase-analytics exited with code 0
supabase-imgproxy               | INFO    [2023-12-07T09:59:46Z] Started /health  request_id=57Pk1ssaIfwbTOkEzY5TP method=GET client_ip=127.0.0.1
supabase-imgproxy               | INFO    [2023-12-07T09:59:46Z] Completed in 187.321µs /health  request_id=57Pk1ssaIfwbTOkEzY5TP method=GET status=200 client_ip=127.0.0.1
supabase-analytics              | warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
supabase-analytics              |   /opt/app/rel/logflare/lib/logflare-1.4.0/priv/repo/migrations/20210322193905_rename_columns_for_mnesia_compatibility.exs:3: Logflare.Repo.Migrations.RenameColumnsForMnesiaCompatibility
supabase-analytics              | 
supabase-analytics              | warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
supabase-analytics              |   /opt/app/rel/logflare/lib/logflare-1.4.0/priv/repo/migrations/20210729161959_subscribe_to_postgres.exs:19: Logflare.Repo.Migrations.SubscribeToPostgres
supabase-analytics              | 
supabase-analytics              | warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
supabase-analytics              |   /opt/app/rel/logflare/lib/logflare-1.4.0/priv/repo/migrations/20210729161959_subscribe_to_postgres.exs:20: Logflare.Repo.Migrations.SubscribeToPostgres
supabase-analytics              | 
supabase-analytics              | warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
supabase-analytics              |   /opt/app/rel/logflare/lib/logflare-1.4.0/priv/repo/migrations/20210729161959_subscribe_to_postgres.exs:21: Logflare.Repo.Migrations.SubscribeToPostgres
supabase-analytics              | 
supabase-analytics              | warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
supabase-analytics              |   /opt/app/rel/logflare/lib/logflare-1.4.0/priv/repo/migrations/20210729161959_subscribe_to_postgres.exs:22: Logflare.Repo.Migrations.SubscribeToPostgres
supabase-analytics              | 
supabase-analytics              | warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
supabase-analytics              |   /opt/app/rel/logflare/lib/logflare-1.4.0/priv/repo/migrations/20210729161959_subscribe_to_postgres.exs:23: Logflare.Repo.Migrations.SubscribeToPostgres
supabase-analytics              | 
supabase-analytics              | warning: an expression is always required on the right side of ->. Please provide a value after ->
supabase-analytics              |   /opt/app/rel/logflare/lib/logflare-1.4.0/priv/repo/migrations/20230727111150_update_endpoint_query_language_default_value.exs:8:13
supabase-analytics              | 
supabase-analytics              | ** (Postgrex.Error) ERROR 42704 (undefined_object) unrecognized configuration parameter "pgsodium.enable_event_trigger"
supabase-analytics              |     (ecto_sql 3.10.1) lib/ecto/adapters/sql.ex:913: Ecto.Adapters.SQL.raise_sql_call_error/1
supabase-analytics              |     (elixir 1.14.4) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
supabase-analytics              |     (ecto_sql 3.10.1) lib/ecto/adapters/sql.ex:1005: Ecto.Adapters.SQL.execute_ddl/4
supabase-analytics              |     (ecto_sql 3.10.1) lib/ecto/migration/runner.ex:327: Ecto.Migration.Runner.log_and_execute_ddl/3
supabase-analytics              |     (ecto_sql 3.10.1) lib/ecto/migration/runner.ex:117: anonymous fn/6 in Ecto.Migration.Runner.flush/0
supabase-analytics              |     (elixir 1.14.4) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
supabase-analytics              |     (ecto_sql 3.10.1) lib/ecto/migration/runner.ex:116: Ecto.Migration.Runner.flush/0
supabase-analytics              |     nofile:1: (file)
supabase-imgproxy               | INFO    [2023-12-07T09:59:51Z] Started /health  request_id=4hANPs0kY_O9vZITWp-qy method=GET client_ip=127.0.0.1
supabase-imgproxy               | INFO    [2023-12-07T09:59:51Z] Completed in 127.59µs /health  request_id=4hANPs0kY_O9vZITWp-qy method=GET status=200 client_ip=127.0.0.1
supabase-imgproxy               | INFO    [2023-12-07T09:59:57Z] Started /health  request_id=-JYx_kvG0U-7IoGk9RJah method=GET client_ip=127.0.0.1
supabase-imgproxy               | INFO    [2023-12-07T09:59:57Z] Completed in 272.68µs /health  request_id=-JYx_kvG0U-7IoGk9RJah method=GET status=200 client_ip=127.0.0.1
supabase-analytics              | Kernel pid terminated (application_controller) ({application_start_failure,logflare,{{shutdown,{failed_to_start_child,'Elixir.Logflare.SystemMetricsSup',{shutdown,{failed_to_start_child,'Elixir.Logflare.SystemMetrics.AllLogsLogged',{#{'__exception__' => true,'__struct__' => 'Elixir.Postgrex.Error',connection_id => 3060497,message => nil,postgres => #{code => undefined_table,file => <<"parse_relation.c">>,line => <<"1392">>,message => <<"relation \"system_metrics\" does not exist">>,pg_code => <<"42P01">>,position => <<"89">>,routine => <<"parserOpenTable">>,severity => <<"ERROR">>,unknown => <<"ERROR">>},query => <<"SELECT s0.\"id\", s0.\"all_logs_logged\", s0.\"node\", s0.\"inserted_at\", s0.\"updated_at\" FROM \"system_metrics\" AS s0 WHERE (s0.\"node\" = $1)">>},[{'Elixir.Ecto.Adapters.SQL',raise_sql_call_error,1,[{file,"lib/ecto/adapters/sql.ex"},{line,913},{error_info,#{module => 'Elixir.Exception'}}]},{'Elixir.Ecto.Adapters.SQL',execute,6,[{file,"lib/ecto/adapters/sql.ex"},{line,828}]},{'Elixir.Ecto.Re
supabase-analytics              | 
supabase-analytics              | Crash dump is being written to: erl_crash.dump...done
supabase-analytics              | sh: 09:59:46.977: not found
supabase-analytics exited with code 127
dependency failed to start: container supabase-analytics is unhealthy

在pgadmin4 上查看到的扩展安装情况:

supa=# \dx
                                            List of installed extensions
        Name        | Version |   Schema   |                              Description                               
--------------------+---------+------------+------------------------------------------------------------------------
 adminpack          | 2.1     | pg_catalog | administrative functions for PostgreSQL
 btree_gin          | 1.3     | public     | support for indexing common datatypes in GIN
 btree_gist         | 1.7     | public     | support for indexing common datatypes in GiST
 file_fdw           | 1.0     | public     | foreign-data wrapper for flat file access
 intagg             | 1.1     | public     | integer aggregator and enumerator (obsolete)
 intarray           | 1.5     | public     | functions, operators, and index support for 1-D arrays of integers
 pageinspect        | 1.11    | monitor    | inspect the contents of database pages at a low level
 pg_buffercache     | 1.3     | monitor    | examine the shared buffer cache
 pg_freespacemap    | 1.2     | monitor    | examine the free space map (FSM)
 pg_graphql         | 1.4.0   | graphql    | pg_graphql: GraphQL support
 pg_net             | 0.7.3   | extensions | Async HTTP
 pg_prewarm         | 1.2     | monitor    | prewarm relation data
 pg_repack          | 1.5.0   | public     | Reorganize tables in PostgreSQL databases with minimal locks
 pg_stat_statements | 1.10    | monitor    | track planning and execution statistics of all SQL statements executed
 pg_trgm            | 1.6     | public     | text similarity measurement and index searching based on trigrams
 pg_visibility      | 1.2     | monitor    | examine the visibility map (VM) and page-level visibility info
 pgcrypto           | 1.3     | extensions | cryptographic functions
 pgjwt              | 0.2.0   | extensions | JSON Web Token API for Postgresql
 pgsodium           | 3.1.9   | pgsodium   | Pgsodium is a modern cryptography library for Postgres.
 pgstattuple        | 1.5     | monitor    | show tuple-level statistics
 plpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgres_fdw       | 1.1     | public     | foreign-data wrapper for remote PostgreSQL servers
 supabase_vault     | 0.2.8   | vault      | Supabase Vault Extension
 uuid-ossp          | 1.1     | extensions | generate universally unique identifiers (UUIDs)
(24 rows)

操作系统信息:

[12-07 18:00:01] michael@rocky9Pigsty:~/pigsty/app/supabase 
$ cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.3"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.3"
Vonng commented 7 months ago

Seems like a problem with pgsodium

unrecognized configuration parameter "pgsodium.enable_event_trigger"

Which pigsty version, config template is used? and can you config cluster with pgsodium.enable_event_trigger = 'off';

Michael2008S commented 7 months ago
image

Pigsty v2.5.1

根据默认配置生成,再把supa的 yaml 合并过来的配置:

---
#==============================================================#
# File      :   el.yml
# Desc      :   Pigsty auto generated config for el8, el9
# Ctime     :   2020-05-22
# Mtime     :   2023-03-31
# Docs      :   https://doc.pigsty.cc/#/CONFIG
# Author    :   Ruohang Feng (rh@vonng.com)
# License   :   AGPLv3
#==============================================================#

# this is a simple singleton meta config template, check full details with
# https://github.com/Vonng/pigsty/blob/master/files/pigsty/full.yml

all:
  children:

    # infra cluster for proxy, monitor, alert, etc..
    infra: { hosts: { 192.168.18.172: { infra_seq: 1 } } }

    # minio cluster, optional backup repo for pgbackrest
    minio: { hosts: { 192.168.18.172: { minio_seq: 1 } }, vars: { minio_cluster: minio } }

    # etcd cluster for ha postgres
    etcd: { hosts: { 192.168.18.172: { etcd_seq: 1 } }, vars: { etcd_cluster: etcd } }

    # postgres cluster 'pg-meta' with single primary instance
    pg-meta:
      hosts: { 192.168.18.172: { pg_seq: 1, pg_role: primary } }
      vars:
        pg_cluster: pg-meta
        pg_libs: 'pg_net, pg_stat_statements, auto_explain' # add extra extensions to shared_preload_libraries
        pg_extensions:                                        # required extensions
          - pg_repack_${pg_version}* wal2json_${pg_version}* pgvector_${pg_version}* pg_cron_${pg_version}* pgsodium_${pg_version}*
          - vault_${pg_version}* pg_graphql_${pg_version}* pgjwt_${pg_version}* pg_net_${pg_version}* pgsql-http_${pg_version}*
        node_crontab: [ '00 01 * * * postgres /pg/bin/pg-backup full' ] # make a full backup every 1am
        pg_users:
          - { name: dbuser_meta ,password: DBUser.Meta   ,pgbouncer: true ,roles: [ dbrole_admin ]    ,comment: pigsty admin user }
          - { name: dbuser_view ,password: DBUser.Viewer ,pgbouncer: true ,roles: [ dbrole_readonly ] ,comment: read-only viewer for meta database }
          # supabase roles: anon, authenticated, dashboard_user
          - { name: anon           ,login: false }
          - { name: authenticated  ,login: false }
          - { name: dashboard_user ,login: false ,replication: true ,createdb: true ,createrole: true }
          - { name: service_role   ,login: false ,bypassrls: true }
          # supabase users: please use the same password
          - { name: supabase_admin             ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: true   ,superuser: true ,replication: true ,createdb: true ,createrole: true ,bypassrls: true }
          - { name: authenticator              ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false  ,roles: [ authenticated ,anon ,service_role ] }
          - { name: supabase_auth_admin        ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false  ,createrole: true }
          - { name: supabase_storage_admin     ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false  ,createrole: true ,roles: [ authenticated ,anon ,service_role ] }
          - { name: supabase_functions_admin   ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false  ,createrole: true }
          - { name: supabase_replication_admin ,password: 'DBUser.Supa' ,replication: true }
          - { name: supabase_read_only_user    ,password: 'DBUser.Supa' ,bypassrls: true ,roles: [ pg_read_all_data ] }
        pg_databases: 
          - { name: meta ,baseline: cmdb.sql ,comment: pigsty meta database ,schemas: [ pigsty ] ,extensions: [{name: postgis, schema: public}] }
          - name: supa
            baseline: supa.sql    # the init-scripts: https://github.com/supabase/postgres/tree/develop/migrations/db/init-scripts
            owner: supabase_admin
            comment: supabase postgres database
            schemas: [ extensions ,auth ,realtime ,storage ,graphql_public ,supabase_functions ,_analytics ,_realtime ]
            extensions:
              - { name: pgcrypto  ,schema: extensions  } # 1.3   : cryptographic functions
              - { name: pg_net    ,schema: extensions  } # 0.7.1 : Async HTTP
              - { name: pgjwt     ,schema: extensions  } # 0.2.0 : JSON Web Token API for Postgresql
              - { name: uuid-ossp ,schema: extensions  } # 1.1   : generate universally unique identifiers (UUIDs)
              - { name: pgsodium        }                # 3.1.8 : pgsodium is a modern cryptography library for Postgres.
              - { name: supabase_vault  }                # 0.2.8 : Supabase Vault Extension
              - { name: pg_graphql      }                # 1.3.0 : pg_graphql: GraphQL support
        pg_hba_rules:
          - { user: all ,db: supa ,addr: intra       ,auth: pwd ,title: 'allow supa database access from intranet'}
          - { user: all ,db: supa ,addr: 172.0.0.0/8 ,auth: pwd ,title: 'allow supa database access from docker network'}

  vars:                               # global parameters
    version: v2.5.1                   # pigsty version string
    admin_ip: 192.168.18.172             # admin node ip address
    region: default                   # upstream mirror region: default,china,europe
    node_tune: tiny                   # use tiny template for NODE  in demo environment
    pg_conf: tiny.yml                 # use tiny template for PGSQL in demo environment

    infra_portal:                     # domain names and upstream servers
      home         : { domain: h.pigsty }
      grafana      : { domain: g.pigsty ,endpoint: "${admin_ip}:3000" , websocket: true }
      prometheus   : { domain: p.pigsty ,endpoint: "${admin_ip}:9090" }
      alertmanager : { domain: a.pigsty ,endpoint: "${admin_ip}:9093" }
      blackbox     : { endpoint: "${admin_ip}:9115" }
      loki         : { endpoint: "${admin_ip}:3100" }
      minio        : { domain: sss.pigsty  ,endpoint: "${admin_ip}:9001" ,scheme: https ,websocket: true }
      postgrest    : { domain: api.pigsty  ,endpoint: "${admin_ip}:8884" }
      pgadmin      : { domain: adm.pigsty  ,endpoint: "${admin_ip}:8885" }
      pgweb        : { domain: cli.pigsty  ,endpoint: "${admin_ip}:8886" }
      bytebase     : { domain: ddl.pigsty  ,endpoint: "${admin_ip}:8887" }
      supa         : { domain: supa.pigsty ,endpoint: "${admin_ip}:8000", websocket: true }

    nginx_navbar:                    # application nav links on home page
      - { name: PgAdmin4   , url : 'http://adm.pigsty'  , comment: 'PgAdmin4 for PostgreSQL'  }
      - { name: PGWeb      , url : 'http://cli.pigsty'  , comment: 'PGWEB Browser Client'     }
      - { name: ByteBase   , url : 'http://ddl.pigsty'  , comment: 'ByteBase Schema Migrator' }
      - { name: PostgREST  , url : 'http://api.pigsty'  , comment: 'Kong API Gateway'         }
      - { name: Gitea      , url : 'http://git.pigsty'  , comment: 'Gitea Git Service'        }
      - { name: Minio      , url : 'http://sss.pigsty'  , comment: 'Minio Object Storage'     }
      - { name: Wiki       , url : 'http://wiki.pigsty' , comment: 'Local Wikipedia'          }
      - { name: Explain    , url : '/pigsty/pev.html'   , comment: 'pgsql explain visualizer' }
      - { name: Package    , url : '/pigsty'            , comment: 'local yum repo packages'  }
      - { name: PG Logs    , url : '/logs'              , comment: 'postgres raw csv logs'    }
      - { name: Schemas    , url : '/schema'            , comment: 'schemaspy summary report' }
      - { name: Reports    , url : '/report'            , comment: 'pgbadger summary report'  }
    node_timezone: Asia/Hong_Kong     # use Asia/Hong_Kong Timezone
    node_ntp_servers:                 # NTP servers in /etc/chrony.conf
      - pool cn.pool.ntp.org iburst
      - pool ${admin_ip} iburst       # assume non-admin nodes does not have internet access
    pgbackrest_method: minio          # pgbackrest repo method: local,minio,[user-defined...]

    # if you want to use minio as backup repo instead of local fs, uncomment minio related lines
    # don't forget to configure pgbackrest_repo and change credentials there!
    #pgbackrest_method: minio

    # if disabled, original /etc/yum.repos.d will be kept
    repo_remove: true       # remove existing repo on admin node during repo bootstrap
    node_repo_remove: true  # remove existing node repo for node managed by pigsty

    # WARNING: CHANGE THESE PASSWORDS
    #grafana_admin_username: admin
    grafana_admin_password: pigsty
    #pg_admin_username: dbuser_dba
    pg_admin_password: DBUser.DBA
    #pg_monitor_username: dbuser_monitor
    pg_monitor_password: DBUser.Monitor
    #pg_replication_username: replicator
    pg_replication_password: DBUser.Replicator
    #patroni_username: postgres
    patroni_password: Patroni.API
    #haproxy_admin_username: admin
    haproxy_admin_password: pigsty

    # this config template assume you are using pre-packed offline packages
    # If you wish to download upstream yum packages directly from internet,
    # consider using ad hoc `el7.yml`, `el8.yml`, `el9.yml` config instead.
...

not sure how to config the pgsodium.enable_event_trigger = 'off';

Michael2008S commented 7 months ago

使用下面方法disable enable_event_trigger 可以运行:

To set up pgsodium.enable_event_trigger = 'off', you need to modify the configuration of your PostgreSQL database where the pgsodium extension is installed. pgsodium is an extension for PostgreSQL that provides cryptographic functions. Here's how you can set the enable_event_trigger setting to 'off':

Access the PostgreSQL Command Line: You need to have administrative access to the PostgreSQL server. Connect to your PostgreSQL database using a command-line tool like psql or a graphical interface such as pgAdmin.

Check if pgsodium is Installed: Before changing any settings, ensure that the pgsodium extension is installed in your database. You can check this by running the following SQL query:

SELECT * FROM pg_extension WHERE extname = 'pgsodium';

Modify the Configuration: You can change the pgsodium.enable_event_trigger setting by executing the following SQL command:

ALTER DATABASE supa SET pgsodium.enable_event_trigger TO 'off';

Replace your_database_name with the name of your database.

Reload the Configuration: After changing the setting, you may need to reload the database configuration to apply the changes. This can be done with the following SQL command:

SELECT pg_reload_conf();

Verify the Setting: After reloading the configuration, you can verify that the setting has been applied by querying the current setting:

SHOW pgsodium.enable_event_trigger;

Restart the PostgreSQL Service (if necessary): In some cases, you might need to restart the PostgreSQL service for the changes to take effect. This depends on your PostgreSQL setup and environment.

Remember that altering database configurations can have other effects, so make sure you understand the implications of this change, especially if you're working in a production environment.

Vonng commented 5 months ago

Add notice to the supabase setup doc: https://github.com/Vonng/pigsty/tree/master/app/supabase#database