Microsoft SQLServer DB migration fails when upgrading SonarQube DE from 9.9.0 LTS to 10.4.1

Hi Collin,

we deleted the index, and the colomn got dropped successfully.
Why did this happen to the database, as far as I know we’ve done no manual modifications.

Yet we try and error the upgrade by removing the “blocking” index iteratively.

org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #100002 'Drop column 'module_uuid' in the 'Components' table' failed
...
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The index 'IX_components__branch_uuid' is dependent on column 'module_uuid'.
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #102024 'Drop 'purge_status' column in 'snapshots' table' failed
...
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The index 'IX_snapshots__component_uuid_islast_purge_status' is dependent on column 'purge_status'.

After we deleted those two indices the Database was up-tp-date. But still the SonarQube Server is not starting:

2024.04.12 14:17:26 INFO  web[][o.s.s.p.DetectPluginChange] Detect plugin changes
2024.04.12 14:17:26 INFO  web[][o.s.s.p.DetectPluginChange] No plugin change detected
2024.04.12 14:17:27 INFO  web[][o.h.v.i.util.Version] HV000001: Hibernate Validator null
2024.04.12 14:17:28 WARN  web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd-org.sonar.server.es.IndexCreator': Initialization of bean failed; nested exception is java.lang.NullPointerException: Cannot invoke "org.elasticsearch.common.document.DocumentField.getValue()" because "field" is null
2024.04.12 14:17:28 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd-org.sonar.server.es.IndexCreator': Initialization of bean failed; nested exception is java.lang.NullPointerException: Cannot invoke "org.elasticsearch.common.document.DocumentField.getValue()" because "field" is null
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:920)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:222)
	at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)
	at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:687)
	at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:214)
	at org.sonar.server.platform.PlatformImpl.startLevel34Containers(PlatformImpl.java:194)
	at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.runIfNotAborted(PlatformImpl.java:362)
	at org.sonar.server.platform.PlatformImpl$1.doRun(PlatformImpl.java:113)
	at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.run(PlatformImpl.java:346)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NullPointerException: Cannot invoke "org.elasticsearch.common.document.DocumentField.getValue()" because "field" is null
	at org.sonar.server.es.metadata.MetadataIndexImpl.getMetadata(MetadataIndexImpl.java:97)
	at org.sonar.server.es.metadata.MetadataIndexImpl.getDbVendor(MetadataIndexImpl.java:83)
	at org.sonar.server.es.metadata.EsDbCompatibilityImpl.hasSameDbVendor(EsDbCompatibilityImpl.java:37)
	at org.sonar.server.es.IndexCreator.checkDbCompatibility(IndexCreator.java:183)
	at org.sonar.server.es.IndexCreator.start(IndexCreator.java:87)
	at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
	... 17 common frames omitted
2024.04.12 14:17:29 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process
2024.04.12 14:17:29 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown initiated...
2024.04.12 14:17:29 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown completed.

The issue seems to be known Sonarqube10 deployment error but the resolution does not fit to our usecase.

Thanks in advance
Thomas