Unable to use postgres DB with SonarQube 9.9 LTS

Hi all, in our company we upgraded from SonarQube 9.8 to SQ 9.9 LTS. But all went bad. We use a postgres DB that was completely destroyed by the new instance. Moreover the ID changed (without any explainable reason) and now we are unable to use the postgres DB.

  • System Information:
  • Docker SonarQube;
  • DB Postgres 14.5 (via Docker image)
    The command lines we use are:
  • to launch the postgres docker:
    docker run --restart unless-stopped --name sonar-postgres -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pwd -p 5432:5432 --network sonarqube_network -d postgres

  • to launch the sonarqube docker:

docker volume create --name sonarqube_data
docker volume create --name sonarqube_logs
docker volume create --name sonarqube_extensions
docker run --restart unless-stopped --name sonarqube -p 9000:9000 -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -e SONARQUBE_JDBC_USERNAME=user -e SONARQUBE_JDBC_PASSWORD=pwd -e SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-postgres:5432/sonar -v sonarqube_data:/opt/sonarqube/data -v sonarqube_extensions:/opt/sonarqube/extensions -v sonarqube_logs:/opt/sonarqube/logs -d --net sonarqube_network sonarqube:lts-developer 

The problem is that The SQ Instance doesn’t even try to connect the Postgres DB

Any suggestion on how to restore a functional instance?

Hi,

Could you explain what this means?

Do you mean your server ID? That will happen if your DB URL changes. When you upgraded your DB, I guess it ended up at a new URL? Can you put it back or set up an alias?

Sounds like it’s missing the DB connection details? I see you’ve included them in your run command. What do your server logs say?

 
Ann

  1. We tried to open the db (after the migration) with the postgres client and the db was completely empty (no more users, or any other information)
  2. The run commands are exactly the same we used with the previous version of SQ. No DB URL changes occured.
  3. I have the log, but I cannot find a way to attach it to my posts (as I cannot find a way to quote your question in this answer).

update: I found how to upload the log
docker_sonar.log (22.1 KB)

update 2: We connected to the docker image and we can see that the environment variable are correctly set. But SQ seems to ignore them

Hi,

Ehm…

What did you give SonarQube permissions to? In your DB upgrade, I’d have expected you to retain the same SQ schema, data, user and permissions. I’m not aware of any circumstance in which SonarQube would wipe out its own schema, much less the entire DB. I suspect some other process went awry here.

And since you’ve said that SonarQube didn’t connect to the DB and your log shows that H2 is in use… I don’t think there are any reasons to blame SonarQube here.

Then can you explain what ID changed?

Right… The changes occurred on our end. It’s always good to check the Release upgrade notes.

 
HTH,
Ann