Version 9.9 cannot connect to postgres 13.6

I am upgrading with docker compose from version 9.8 to 9.9. I use this docker compose in version 9.8 and it works ok:

services:
  postgres-sonarqube:
    image: postgres:13.6
    container_name: postgres-sonarqube
    ports:
      - 5432:5432
    environment: 
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass
    volumes:
      - vu00445_postgres-sonarqube_data:/var/lib/postgresql/data
  sonarqube:
    links: 
      - "postgres-sonarqube:database"
    image: sonarqube:9.8-community
    container_name: sonarqube
    depends_on:
      - postgres-sonarqube
    ports:
      - 9000:9000
    environment: 
      - sonar.jdbc.username=user
      - sonar.jdbc.password=pass
      - sonar.jdbc.url=jdbc:postgresql://database:5432/sonar
    volumes:
      - vu00445_sonarqube_data:/opt/sonarqube/data
      - vu00445_sonarqube_extensions:/opt/sonarqube/extensions
      - vu00445_sonarqube_logs:/opt/sonarqube/logs
      - vu00445_sonarqube_conf:/opt/sonarqube/conf
      - vu00445_sonarqube_cacerts:/etc/ssl/certs/java
volumes:
  vu00445_sonarqube_data:
    external: true
  vu00445_sonarqube_extensions:
    external: true
  vu00445_sonarqube_logs:
    external: true
  vu00445_sonarqube_conf:
    external: true
  vu00445_sonarqube_cacerts:
    external: true
  vu00445_postgres-sonarqube_data:
    external: true

I use this docker compose in version 9.9 and it cannot connect to postgres 13.6:

services:
  postgres-sonarqube:
    image: postgres:13.6
    container_name: postgres-sonarqube
    ports:
      - 5432:5432
    environment: 
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass
    volumes:
      - vu00445_postgres-sonarqube_data:/var/lib/postgresql/data
  sonarqube:
    links: 
      - "postgres-sonarqube:database"
    image: sonarqube:9.9-community
    container_name: sonarqube
    depends_on:
      - postgres-sonarqube
    ports:
      - 9000:9000
    environment: 
      - sonar.jdbc.username=user
      - sonar.jdbc.password=pass
      - sonar.jdbc.url=jdbc:postgresql://database:5432/sonar
    volumes:
      - vu00445_sonarqube_data:/opt/sonarqube/data
      - vu00445_sonarqube_extensions:/opt/sonarqube/extensions
      - vu00445_sonarqube_logs:/opt/sonarqube/logs
      - vu00445_sonarqube_conf:/opt/sonarqube/conf
      - vu00445_sonarqube_cacerts:/etc/ssl/certs/java
volumes:
  vu00445_sonarqube_data:
    external: true
  vu00445_sonarqube_extensions:
    external: true
  vu00445_sonarqube_logs:
    external: true
  vu00445_sonarqube_conf:
    external: true
  vu00445_sonarqube_cacerts:
    external: true
  vu00445_postgres-sonarqube_data:
    external: true

Inside sonarqube, I don’t have any error, but it connects to the H2 base (which is wrong), part of the log from the sonarqube container:

2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][o.s.p.ProcessEntryPoint] Starting Web Server
2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][o.s.s.p.LogServerVersion] SonarQube Server / 9.9.0.65466 / ce743843018827cb30c05735e7971523de34bb48
2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][o.s.s.p.d.EmbeddedDatabase] Starting embedded database on port 9092 with url jdbc:h2:tcp://127.0.0.1:9092/sonar;NON_KEYWORDS=VALUE
2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][o.s.s.p.d.EmbeddedDatabase] Embedded database started. Data stored in: /opt/sonarqube/data
2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][o.sonar.db.Database] Create JDBC data source for jdbc:h2:tcp://127.0.0.1:9092/sonar;NON_KEYWORDS=VALUE
2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Starting...
2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][c.z.h.p.HikariPool] HikariPool-1 - Added connection conn2: url=jdbc:h2:tcp://127.0.0.1:9092/sonar user=
2023-02-17 15:05:01 2023.02.17 14:05:01 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Start completed.
2023-02-17 15:05:01 2023.02.17 14:05:01 WARN  web[][o.s.db.dialect.H2] H2 database should be used for evaluation purpose only.
2023-02-17 15:05:02 2023.02.17 14:05:02 INFO  web[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /opt/sonarqube
2023-02-17 15:05:02 2023.02.17 14:05:02 INFO  web[][o.s.s.u.SystemPasscodeImpl] System authentication by passcode is disabled
2023-02-17 15:05:02 2023.02.17 14:05:02 INFO  web[][o.s.s.p.d.m.h.MigrationHistoryTableImpl] Creating table schema_migrations

Log from postgres 13.6 container:

2023-02-17 15:04:55 2023-02-17 14:04:55.443 UTC [1] LOG:  starting PostgreSQL 13.6 (Debian 13.6-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-02-17 15:04:55 2023-02-17 14:04:55.443 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-02-17 15:04:55 2023-02-17 14:04:55.443 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-02-17 15:04:55 2023-02-17 14:04:55.445 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-02-17 15:04:55 2023-02-17 14:04:55.449 UTC [26] LOG:  database system was shut down at 2023-02-17 14:03:09 UTC
2023-02-17 15:04:55 2023-02-17 14:04:55.452 UTC [1] LOG:  database system is ready to accept connections
2023-02-17 17:05:30 2023-02-17 16:05:30.912 UTC [1] LOG:  received fast shutdown request
2023-02-17 17:05:30 2023-02-17 16:05:30.914 UTC [1] LOG:  aborting any active transactions
2023-02-17 17:05:30 2023-02-17 16:05:30.915 UTC [1] LOG:  background worker "logical replication launcher" (PID 32) exited with exit code 1
2023-02-17 17:05:30 2023-02-17 16:05:30.915 UTC [27] LOG:  shutting down
2023-02-17 17:05:30 2023-02-17 16:05:30.925 UTC [1] LOG:  database system is shut down
2023-02-20 10:12:05 2023-02-20 09:12:05.905 UTC [1] LOG:  starting PostgreSQL 13.6 (Debian 13.6-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-02-20 10:12:05 2023-02-20 09:12:05.905 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-02-20 10:12:05 2023-02-20 09:12:05.905 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-02-20 10:12:05 2023-02-20 09:12:05.908 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-02-20 10:12:05 2023-02-20 09:12:05.912 UTC [25] LOG:  database system was shut down at 2023-02-17 16:05:30 UTC
2023-02-20 10:12:05 2023-02-20 09:12:05.916 UTC [1] LOG:  database system is ready to accept connections
2023-02-17 15:04:55 
2023-02-17 15:04:55 PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-02-17 15:04:55 
2023-02-20 10:12:05 
2023-02-20 10:12:05 PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-02-20 10:12:05

Any help would be nice…

Hey there.

These aren’t proper environment variables – you can find the correct ones documented here.

1 Like

Thanks Colin, that solved the problem.

1 Like

Hi @Colin

Same issue for us, but we are using the cloudformation template to deploy to ECS, we checked the upgrade notes, but couldn’t find anything relevant to this, i am sharing our configuration file details which we will be passing in cloudformation template

this is our configuration file, which is configured to connect to external DB
`dbUsername=postgres dbUrl=jdbc:postgresql://xxxxxxs.eu-central-1.rds.amazonaws.com:5432/sonar azureClientID=abc ClusterName=xxxx ImageName=sonarqube:9.9.0-community

all the projects are loading when we are running on sonarqube 9.8.0 version but when we use the same db configuration, for sonarqube 9.9.0 then it is showing H2 database should be used…then i rolled back the sonarqube from 9.9.0 to sonarqube 9.8.0 then it is loading all the projects…so i want to know why this is happening eventhough we specify the correct db configuration and it is working for 9.8.0 but not for 9.9.0

when we go inside the docker container, then we can’t find run.sh and sonar.sh files under /opt/sonarqube/bin

Below is the screenshot

the docker image we are using is given below

Hey there.

Where did you get the CloudFormation template from?

This solves my problem. Thanks. Documentation needs to be updated.

Hey there.

Which documentation?