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

Issue with Postgres database #275

Open
ALIP-0 opened this issue Jun 17, 2024 · 2 comments
Open

Issue with Postgres database #275

ALIP-0 opened this issue Jun 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ALIP-0
Copy link

ALIP-0 commented Jun 17, 2024

With postgres configured wgportal creates a number of tables and data, however when i login and goto the interfaces screen no interfaces are shown, despite one being configured in the db table - i get the following error;

Failed to load interfaces: unable to load all interfaces: ERROR: prepared statement "stmtcache_78bc77220c7a756ffad09fd606f629b582d36975c88309a4" already exists (SQLSTATE 42P05)

@h44z h44z added the bug Something isn't working label Jul 4, 2024
@ALIP-0
Copy link
Author

ALIP-0 commented Jul 20, 2024

Just wondering if someone else could try this and let me know how you get on? Is it an actual bug or is it just me/my configuration ?

Edit: I have tested this again with a new config and have the same result.

@bonddim
Copy link
Collaborator

bonddim commented Nov 26, 2024

@ALIP-0
Can't reproduce on latest version of v2.
Running both via docker compose.
Interface is shown after re-login and after wg-portal container restart.

# docker-compose.yaml
services:
  wg-portal:
    image: ghcr.io/h44z/wg-portal:latest
    cap_add:
      - NET_ADMIN
    ports:
      - 8888:8888
      - 8080:8080
    volumes:
      - ./config.yml.sample:/app/config/config.yml

  # Example from image docs https://hub.docker.com/_/postgres
  postgres:
    image: postgres
    restart: always
    # set shared memory limit when using docker-compose
    shm_size: 128mb
    # or set shared memory limit when deploy via swarm stack
    #volumes:
    #  - type: tmpfs
    #    target: /dev/shm
    #    tmpfs:
    #      size: 134217728 # 128*2^20 bytes = 128Mb
    environment:
      POSTGRES_PASSWORD: example
# config.yml
advanced:
  log_level: trace
  config_storage_path: /etc/wireguard

core:
  admin_user: admin
  admin_password: admin
  create_default_peer: false
  create_default_peer_on_creation: false
  
web:
  external_url: http://localhost:8888
  request_logging: false

database:
  type: postgres
  dsn: "host=postgres user=postgres password=example dbname=postgres port=5432 sslmode=disable"
WG-Portal logs
wg-portal  | time="2024-11-26T21:33:15Z" level=info msg="Starting WireGuard Portal V2..."
wg-portal  | time="2024-11-26T21:33:15Z" level=info msg="WireGuard Portal version: master-90a570b"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="WireGuard Portal Features:"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - EditableKeys: false"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - CreateDefaultPeerOnCreation: false"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - SelfProvisioningAllowed: false"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - ImportExisting: true"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - RestoreState: true"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - UseIpV6: true"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - CollectInterfaceData: false"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - CollectPeerData: false"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - CollectAuditData: false"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="WireGuard Portal Settings:"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - ConfigStoragePath: /etc/wireguard"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - ExternalUrl: http://localhost:8888"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="WireGuard Portal Authentication:"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - OIDC Providers: 0"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - OAuth Providers: 0"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="  - Ldap Providers: 0"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="sysstat migration: <nil>"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="user migration: <nil>"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="interface migration: <nil>"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="peer migration: <nil>"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="peer status migration: <nil>"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="interface status migration: <nil>"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="audit data migration: <nil>"
wg-portal  | time="2024-11-26T21:33:15Z" level=debug msg="sysstat entry for schema version 1 written"
wg-portal  | time="2024-11-26T21:33:15Z" level=info msg="admin user admin created"
wg-portal  | time="2024-11-26T21:33:15Z" level=info msg="interface state restored"
wg-portal  | time="2024-11-26T21:33:15Z" level=trace msg="started ping checks"
wg-portal  | time="2024-11-26T21:33:15Z" level=info msg="started web service on :8888"
wg-portal  | time="2024-11-26T21:33:15Z" level=info msg="started metrics service on :8080"
wg-portal  | time="2024-11-26T21:33:38Z" level=debug msg="handling route update event: interface updated: wg0"
wg-portal  | time="2024-11-26T21:33:38Z" level=debug msg="handling interface updated event for wg0"
wg-portal  | time="2024-11-26T21:33:38Z" level=debug msg="wg0: using fwmark 0 to handle routes"
wg-portal  | time="2024-11-26T21:33:38Z" level=debug msg="wg0: using routing table 20002 to handle default routes"
wg-portal  | time="2024-11-26T21:33:38Z" level=debug msg="routes synchronized, event: interface updated: wg0"
wg-portal  | time="2024-11-26T21:33:47Z" level=debug msg="handling route update event: peers updated"
wg-portal  | time="2024-11-26T21:33:47Z" level=debug msg="handling peer interface updated event for wg0"
wg-portal  | time="2024-11-26T21:33:47Z" level=debug msg="wg0: using fwmark 0 to handle routes"
wg-portal  | time="2024-11-26T21:33:47Z" level=debug msg="wg0: using routing table 20002 to handle default routes"
wg-portal  | time="2024-11-26T21:33:47Z" level=debug msg="routes synchronized, event: peers updated"
wg-portal  | time="2024-11-26T21:34:07Z" level=info msg="Stopping WireGuard Portal"
wg-portal  | time="2024-11-26T21:34:07Z" level=info msg="metrics service on :8080 shutdown gracefully"
wg-portal  | time="2024-11-26T21:34:07Z" level=debug msg="web service shutting down, grace period: 5 seconds..."
wg-portal  | time="2024-11-26T21:34:07Z" level=trace msg="stopped ping checks"
wg-portal  | time="2024-11-26T21:34:07Z" level=info msg="web service on :8888 exited: http: Server closed"
wg-portal  | time="2024-11-26T21:34:07Z" level=debug msg="web service shut down"
wg-portal  | time="2024-11-26T21:34:12Z" level=info msg="Stopped WireGuard Portal"
wg-portal  | time="2024-11-26T21:34:13Z" level=info msg="Starting WireGuard Portal V2..."
wg-portal  | time="2024-11-26T21:34:13Z" level=info msg="WireGuard Portal version: master-90a570b"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="WireGuard Portal Features:"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - EditableKeys: false"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - CreateDefaultPeerOnCreation: false"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - SelfProvisioningAllowed: false"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - ImportExisting: true"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - RestoreState: true"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - UseIpV6: true"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - CollectInterfaceData: false"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - CollectPeerData: false"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - CollectAuditData: false"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="WireGuard Portal Settings:"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - ConfigStoragePath: /etc/wireguard"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - ExternalUrl: http://localhost:8888"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="WireGuard Portal Authentication:"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - OIDC Providers: 0"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - OAuth Providers: 0"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="  - Ldap Providers: 0"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="sysstat migration: <nil>"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="user migration: <nil>"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="interface migration: <nil>"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="peer migration: <nil>"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="peer status migration: <nil>"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="interface status migration: <nil>"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="audit data migration: <nil>"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="skipping default user creation - admin user already exists"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="creating missing interface wg0..."
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="handling route update event: interface updated: wg0"
wg-portal  | time="2024-11-26T21:34:13Z" level=info msg="interface state restored"
wg-portal  | time="2024-11-26T21:34:13Z" level=trace msg="started ping checks"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="handling interface updated event for wg0"
wg-portal  | time="2024-11-26T21:34:13Z" level=info msg="started web service on :8888"
wg-portal  | time="2024-11-26T21:34:13Z" level=info msg="started metrics service on :8080"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="wg0: using fwmark 0 to handle routes"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="wg0: using routing table 20002 to handle default routes"
wg-portal  | time="2024-11-26T21:34:13Z" level=debug msg="routes synchronized, event: interface updated: wg0"
Postgres logs
postgres-1  | The files belonging to this database system will be owned by user "postgres".
postgres-1  | This user must also own the server process.
postgres-1  | 
postgres-1  | The database cluster will be initialized with locale "en_US.utf8".
postgres-1  | The default database encoding has accordingly been set to "UTF8".
postgres-1  | The default text search configuration will be set to "english".
postgres-1  | 
postgres-1  | Data page checksums are disabled.
postgres-1  | 
postgres-1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres-1  | creating subdirectories ... ok
postgres-1  | selecting dynamic shared memory implementation ... posix
postgres-1  | selecting default "max_connections" ... 100
postgres-1  | selecting default "shared_buffers" ... 128MB
postgres-1  | selecting default time zone ... Etc/UTC
postgres-1  | creating configuration files ... ok
postgres-1  | running bootstrap script ... ok
postgres-1  | performing post-bootstrap initialization ... ok
postgres-1  | initdb: warning: enabling "trust" authentication for local connections
postgres-1  | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
postgres-1  | syncing data to disk ... ok
postgres-1  | 
postgres-1  | 
postgres-1  | Success. You can now start the database server using:
postgres-1  | 
postgres-1  |     pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres-1  | 
postgres-1  | waiting for server to start....2024-11-26 21:33:10.125 UTC [48] LOG:  starting PostgreSQL 17.2 (Debian 17.2-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
postgres-1  | 2024-11-26 21:33:10.128 UTC [48] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres-1  | 2024-11-26 21:33:10.137 UTC [51] LOG:  database system was shut down at 2024-11-26 21:33:09 UTC
postgres-1  | 2024-11-26 21:33:10.144 UTC [48] LOG:  database system is ready to accept connections
postgres-1  |  done
postgres-1  | server started
postgres-1  | 
postgres-1  | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres-1  | 
postgres-1  | waiting for server to shut down...2024-11-26 21:33:10.285 UTC [48] LOG:  received fast shutdown request
postgres-1  | .2024-11-26 21:33:10.288 UTC [48] LOG:  aborting any active transactions
postgres-1  | 2024-11-26 21:33:10.290 UTC [48] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
postgres-1  | 2024-11-26 21:33:10.290 UTC [49] LOG:  shutting down
postgres-1  | 2024-11-26 21:33:10.292 UTC [49] LOG:  checkpoint starting: shutdown immediate
postgres-1  | 2024-11-26 21:33:10.307 UTC [49] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.002 s, total=0.017 s; sync files=2, longest=0.002 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/14E4FA0, redo lsn=0/14E4FA0
postgres-1  | 2024-11-26 21:33:10.311 UTC [48] LOG:  database system is shut down
postgres-1  |  done
postgres-1  | server stopped
postgres-1  | 
postgres-1  | PostgreSQL init process complete; ready for start up.
postgres-1  | 
postgres-1  | 2024-11-26 21:33:10.425 UTC [1] LOG:  starting PostgreSQL 17.2 (Debian 17.2-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
postgres-1  | 2024-11-26 21:33:10.426 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres-1  | 2024-11-26 21:33:10.426 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres-1  | 2024-11-26 21:33:10.435 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres-1  | 2024-11-26 21:33:10.446 UTC [62] LOG:  database system was shut down at 2024-11-26 21:33:10 UTC
postgres-1  | 2024-11-26 21:33:10.454 UTC [1] LOG:  database system is ready to accept connections
postgres-1  | 2024-11-26 21:33:15.058 UTC [66] ERROR:  relation "database_migration_infos" does not exist at character 15
postgres-1  | 2024-11-26 21:33:15.058 UTC [66] STATEMENT:  SELECT * FROM "database_migration_infos" ORDER BY applied desc, version desc,"database_migration_infos"."version" LIMIT $1
postgres-1  | 2024-11-26 21:34:13.566 UTC [70] ERROR:  relation "database_migration_infos" does not exist at character 15
postgres-1  | 2024-11-26 21:34:13.566 UTC [70] STATEMENT:  SELECT * FROM "database_migration_infos" ORDER BY applied desc, version desc,"database_migration_infos"."version" LIMIT $1
postgres-1  | 2024-11-26 21:38:10.014 UTC [60] LOG:  checkpoint starting: time
postgres-1  | 2024-11-26 21:38:25.806 UTC [60] LOG:  checkpoint complete: wrote 159 buffers (1.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=15.732 s, sync=0.040 s, total=15.792 s; sync files=97, longest=0.003 s, average=0.001 s; distance=657 kB, estimate=657 kB; lsn=0/15897C8, redo lsn=0/1589738

Did you resolve the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants