SonarQube Fails to Start When Upgrading to PostgreSQL10

I upgraded from Sonarqube 6.7 to 7.8 successfully. When I upgrade my database version from Postgres 9.6.9 to 9.6.11 it works great. However, once I try to upgrade from any 9.6.x version of Postgres to 10.6 via the AWS RDS interface, it breaks my Sonarqube.

I have attempted this upgrade multiple times on multiple version of SonarQube 7.x. I have tried upgrading to the latest version of Postgres 9 before going to 10.6.

Once I try upgrading my database to Postgres 10.6 Sonarqube no longer will start. The web logs say:

“Web server startup failed” “Failed to read content of table schema_migrations” “Error: relation “schema_migrations” does not exist” “o.s.p.ProcessEntryPoint Hard stopping Process”

Hi @naota,

I suggest you connect to the DB with any tool of your choice and check table SCHEMA_MIGRATIONS exists. If so, double check you provided SQ with the same connection details you used with this other tool.

Cheers,

Hi @naota

I have a similar issue and the version what we have installed is PostgreSQL is 11.X and when we try to start the sonar cube it’s giving me the below error. I verified with our DBA team and they have granted all sorts of permission for accessing and write on the database. Can you help me on resolving the issue.
Sonar cube version is : sonarqube-8.1.0.31237

 2019.12.31 17:34:24 INFO  web[][o.s.s.p.LogServerVersion] SonarQube Server / 8.1.0.31237 / 492562ade8941108d7bd281ea9c1cebcf0c1fce3
2019.12.31 17:34:24 INFO  web[][o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://XXXXXXX:5432/sonarqube?currentSchema=sonarqube
2019.12.31 17:34:29 INFO  web[][o.s.s.p.ServerFileSystemImpl] SonarQube home: D:\Softwares\Cube\sonarqube-8.1.0.31237
2019.12.31 17:34:29 INFO  web[][o.s.s.u.SystemPasscodeImpl] System authentication by passcode is disabled
2019.12.31 17:34:31 INFO  web[][o.s.s.p.d.m.h.MigrationHistoryTableImpl] Creating table schema_migrations
2019.12.31 17:34:31 ERROR web[][o.s.s.p.PlatformImpl] Web server startup failed
java.lang.IllegalStateException: Failed to create table schema_migrations
	at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.start(MigrationHistoryTableImpl.java:48)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:101)
	at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:213)
	at org.sonar.server.platform.PlatformImpl.startLevel2Container(PlatformImpl.java:179)
	at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:87)
	at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.postgresql.util.PSQLException: ERROR: no schema has been selected to create in
  Position: 14
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2497)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2233)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:370)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:311)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:297)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:274)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:269)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.execute(MigrationHistoryTableImpl.java:71)
	at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.createTable(MigrationHistoryTableImpl.java:59)
	at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.start(MigrationHistoryTableImpl.java:45)
	... 15 common frames omitted
2019.12.31 17:34:33 WARN  web[][o.a.c.u.SessionIdGeneratorBase] Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [145] milliseconds.
2019.12.31 17:34:33 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9005
2019.12.31 17:34:33 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

I have the same issue

Log:

2020.01.09 09:57:09 ERROR web[][o.s.s.p.PlatformImpl] Web server startup failed
java.lang.IllegalStateException: Failed to read content of table schema_migrations
        at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.getLastMigrationNumber(MigrationHistoryImpl.java:75)
        at org.sonar.server.platform.db.migration.history.MigrationHistoryMeddler.meddle(MigrationHistoryMeddler.java:45)
        at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.start(MigrationHistoryImpl.java:54)
        at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:42)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
        at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
        at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
        at org.picocontainer.behaviors.Stored.start(Stored.java:110)
        at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
        at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
        at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
        at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)
        at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:107)
        at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:213)
        at org.sonar.server.platform.PlatformImpl.startLevel2Container(PlatformImpl.java:179)
        at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:87)
        at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "schema_migrations" does not exist
  Position: 21
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2497)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2233)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:370)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:311)
        at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:297)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:274)
        at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:225)
        at org.apache.commons.dbcp2.DelegatingStatement.executeQuery(DelegatingStatement.java:329)
        at org.apache.commons.dbcp2.DelegatingStatement.executeQuery(DelegatingStatement.java:329)
        at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.selectVersions(MigrationHistoryImpl.java:97)
        at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.getLastMigrationNumber(MigrationHistoryImpl.java:68)
        ... 26 common frames omitted

Also getting this issue, any solutions?

Upgrading from SonarQube 7.1 to 7.9.2. Switched from MySQL to Postgresql.

Log:

2020.01.21 10:18:59 INFO  web[][o.s.s.p.d.m.h.MigrationHistoryTableImpl] Creating table schema_migrations
2020.01.21 10:18:59 ERROR web[][o.s.s.p.Platform] Web server startup failed
java.lang.IllegalStateException: Failed to create table schema_migrations
        at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.start(MigrationHistoryTableImpl.
        at java.base/java.util.Optional.ifPresent(Optional.java:183)
        at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:107)
        at org.sonar.server.platform.Platform.start(Platform.java:211)
        at org.sonar.server.platform.Platform.startLevel2Container(Platform.java:177)
        at org.sonar.server.platform.Platform.init(Platform.java:87)
        at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextLis
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4817)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5283)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.postgresql.util.PSQLException: ERROR: no schema has been selected to create in
  Position: 14
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
        at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:266)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:175)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:175)
        at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.execute(MigrationHistoryTableImp
        at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.createTable(MigrationHistoryTabl
        at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.start(MigrationHistoryTableImpl.
        ... 15 common frames omitted

Hi guys,

If the final Caused by in your stacktrace is

  • ERROR: no schema has been selected to create in
    

    Then it’s probably about your JDBC URL; I believe you need to make sure schema is in your connection string.

  • Failed to read content of table schema_migrations
    

    then it sounds like there’s something wrong with either the schema or your permissions to it.

 
Ann

1 Like

Any updates on this? Still getting the same error. I have made sure the URL, username, password etc. is updated in sonar.properties.

Caused by: org.postgresql.util.PSQLException: ERROR: no schema has been selected to create in
Position: 14
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2497)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2233)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446)

For me I had to remove the schema bit at the end of:

sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube?currentSchema=my_schema

To:

sonar.jdbc.url=jdbc:postgresql://localhost/*DataBaseName*