Skip to content

MariaDB schema upgrade fails for CloudStack 4.20.0.0 fresh installation on EL9 #10048

@andrea-janna

Description

@andrea-janna
ISSUE TYPE
  • Bug Report
COMPONENT NAME

CLOUDSTACK VERSION
4.20.0.0
CONFIGURATION

N/A

OS / ENVIRONMENT

Rocky Linux 9.5
MariaDB 10.5.22

SUMMARY

When cloudstack-management service starts for the first time on a fresh installation it tries to upgrade the database schema from version 4.0.0 to 4.20.0.0 but it fails with the error "Cannot change column 'id': used in a foreign key constraint 'fk_storage_pool_details__pool_id' of table 'cloud.storage_pool_details'"

STEPS TO REPRODUCE
cloudstack-setup-databases --schema-only cloud:${my_cloudstack_database_password}@192.168.27.120 -m ${my_cloudstack_encryption_password} -k ${my_cloudstack_encryption_password}
cloudstack-setup-management
EXPECTED RESULTS
CloudStack web interface should come up.
ACTUAL RESULTS
CloudStack web interface reports HTTP ERROR 503 Service Unavailable.

--- management-server.log ---
...
2024-12-05 11:15:49,842 INFO  [c.c.u.DatabaseUpgradeChecker] (main:[]) (logid:) Database upgrade must be performed from 4.0.0 to 4.20.0.0
2024-12-05 11:15:49,854 DEBUG [c.c.u.DatabaseUpgradeChecker] (main:[]) (logid:) Running upgrade Upgrade40to41 to upgrade from 4.0.0-4.1.0 to 4.1.0
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- Licensed to the Apache Software Foundation (ASF) under one
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- or more contributor license agreements.  See the NOTICE file
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- distributed with this work for additional information
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- regarding copyright ownership.  The ASF licenses this file
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- to you under the Apache License, Version 2.0 (the
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- "License"); you may not use this file except in compliance
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- with the License.  You may obtain a copy of the License at
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) --
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) --   http://www.apache.org/licenses/LICENSE-2.0
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) --
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- Unless required by applicable law or agreed to in writing,
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- software distributed under the License is distributed on an
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2024-12-05 11:15:49,855 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- KIND, either express or implied.  See the License for the
2024-12-05 11:15:49,856 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- specific language governing permissions and limitations
2024-12-05 11:15:49,856 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- under the License.
2024-12-05 11:15:49,856 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) --;
2024-12-05 11:15:49,856 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) -- Schema upgrade from 4.0.0 to 4.1.0;
2024-12-05 11:15:49,856 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) --;
2024-12-05 11:15:49,856 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) use cloud
2024-12-05 11:15:49,856 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) SET foreign_key_checks = 0
2024-12-05 11:15:49,857 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) alter table vm_template add size bigint unsigned
2024-12-05 11:15:49,880 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) alter table vm_template add state varchar(255)
2024-12-05 11:15:49,912 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) alter table vm_template add update_count bigint unsigned
2024-12-05 11:15:49,932 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) alter table vm_template add updated  datetime
2024-12-05 11:15:49,952 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) alter table storage_pool add storage_provider_id bigint unsigned
2024-12-05 11:15:49,972 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) alter table storage_pool add scope varchar(255)
2024-12-05 11:15:50,008 DEBUG [c.c.u.d.ScriptRunner] (main:[]) (logid:) alter table storage_pool modify id bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL
2024-12-05 11:15:50,017 ERROR [c.c.u.d.ScriptRunner] (main:[]) (logid:) Error executing: alter table storage_pool modify id bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL
2024-12-05 11:15:50,024 ERROR [c.c.u.d.ScriptRunner] (main:[]) (logid:) java.sql.SQLException: Cannot change column 'id': used in a foreign key constraint 'fk_storage_p2024-12-05 11:15:50,028 ERROR [c.c.u.DatabaseUpgradeChecker] (main:[]) (logid:) Unable to execute upgrade script java.sql.SQLException: Cannot change column 'id': used in a foreign key constraint 'fk_storage_pool_details__pool_id' of table 'cloud.storage_pool_details'
        at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:186)
        at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:88)
        at com.cloud.upgrade.DatabaseUpgradeChecker.runScript(DatabaseUpgradeChecker.java:240)
        at com.cloud.upgrade.DatabaseUpgradeChecker.executeUpgrade(DatabaseUpgradeChecker.java:361)
        at com.cloud.upgrade.DatabaseUpgradeChecker.executeUpgrades(DatabaseUpgradeChecker.java:337)
        at com.cloud.upgrade.DatabaseUpgradeChecker.upgrade(DatabaseUpgradeChecker.java:303)
        at com.cloud.upgrade.DatabaseUpgradeChecker.check(DatabaseUpgradeChecker.java:476)
        at org.apache.cloudstack.spring.lifecycle.CloudStackExtendedLifeCycle.checkIntegrity(CloudStackExtendedLifeCycle.java:62)
        at org.apache.cloudstack.spring.lifecycle.CloudStackExtendedLifeCycle.start(CloudStackExtendedLifeCycle.java:52)
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:937)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.loadContext(DefaultModuleDefinitionSet.java:174)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet$2.with(DefaultModuleDefinitionSet.java:143)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.withModule(DefaultModuleDefinitionSet.java:274)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.withModule(DefaultModuleDefinitionSet.java:279)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.withModule(DefaultModuleDefinitionSet.java:262)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.loadContexts(DefaultModuleDefinitionSet.java:131)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.load(DefaultModuleDefinitionSet.java:79)
        at org.apache.cloudstack.spring.module.factory.ModuleBasedContextFactory.loadModules(ModuleBasedContextFactory.java:37)
        at org.apache.cloudstack.spring.module.factory.CloudStackSpringContext.init(CloudStackSpringContext.java:71)
        at org.apache.cloudstack.spring.module.factory.CloudStackSpringContext.<init>(CloudStackSpringContext.java:58)
        at org.apache.cloudstack.spring.module.factory.CloudStackSpringContext.<init>(CloudStackSpringContext.java:62)
        at org.apache.cloudstack.spring.module.web.CloudStackContextLoaderListener.contextInitialized(CloudStackContextLoaderListener.java:53)
        at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:1073)
        at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:572)
        at org.eclipse.jetty.server.handler.ContextHandler.contextInitialized(ContextHandler.java:1002)
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:765)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:379)
        at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1449)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1414)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:916)
        at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:288)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
        at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:426)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.server.Server.start(Server.java:423)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
ool_details__pool_id' of table 'cloud.storage_pool_details'
        at org.eclipse.jetty.server.Server.doStart(Server.java:387)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.apache.cloudstack.ServerDaemon.start(ServerDaemon.java:199)
        at org.apache.cloudstack.ServerDaemon.main(ServerDaemon.java:112)

2024-12-05 11:15:50,030 ERROR [c.c.u.DatabaseUpgradeChecker] (main:[]) (logid:) Unable to upgrade the database com.cloud.utils.exception.CloudRuntimeException: Unable to execute upgrade script
        at com.cloud.upgrade.DatabaseUpgradeChecker.runScript(DatabaseUpgradeChecker.java:246)
        at com.cloud.upgrade.DatabaseUpgradeChecker.executeUpgrade(DatabaseUpgradeChecker.java:361)
        at com.cloud.upgrade.DatabaseUpgradeChecker.executeUpgrades(DatabaseUpgradeChecker.java:337)
        at com.cloud.upgrade.DatabaseUpgradeChecker.upgrade(DatabaseUpgradeChecker.java:303)
        at com.cloud.upgrade.DatabaseUpgradeChecker.check(DatabaseUpgradeChecker.java:476)
        at org.apache.cloudstack.spring.lifecycle.CloudStackExtendedLifeCycle.checkIntegrity(CloudStackExtendedLifeCycle.java:62)
        at org.apache.cloudstack.spring.lifecycle.CloudStackExtendedLifeCycle.start(CloudStackExtendedLifeCycle.java:52)
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:937)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.loadContext(DefaultModuleDefinitionSet.java:174)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet$2.with(DefaultModuleDefinitionSet.java:143)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.withModule(DefaultModuleDefinitionSet.java:274)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.withModule(DefaultModuleDefinitionSet.java:279)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.withModule(DefaultModuleDefinitionSet.java:262)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.loadContexts(DefaultModuleDefinitionSet.java:131)
        at org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.load(DefaultModuleDefinitionSet.java:79)
        at org.apache.cloudstack.spring.module.factory.ModuleBasedContextFactory.loadModules(ModuleBasedContextFactory.java:37)
        at org.apache.cloudstack.spring.module.factory.CloudStackSpringContext.init(CloudStackSpringContext.java:71)
        at org.apache.cloudstack.spring.module.factory.CloudStackSpringContext.<init>(CloudStackSpringContext.java:58)
        at org.apache.cloudstack.spring.module.factory.CloudStackSpringContext.<init>(CloudStackSpringContext.java:62)
        at org.apache.cloudstack.spring.module.web.CloudStackContextLoaderListener.contextInitialized(CloudStackContextLoaderListener.java:53)
        at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:1073)
        at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:572)
        at org.eclipse.jetty.server.handler.ContextHandler.contextInitialized(ContextHandler.java:1002)
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:765)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:379)
        at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1449)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1414)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:916)
        at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:288)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
        at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:426)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.server.Server.start(Server.java:423)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
        at org.eclipse.jetty.server.Server.doStart(Server.java:387)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.apache.cloudstack.ServerDaemon.start(ServerDaemon.java:199)
        at org.apache.cloudstack.ServerDaemon.main(ServerDaemon.java:112)
Caused by: java.sql.SQLException: Cannot change column 'id': used in a foreign key constraint 'fk_storage_pool_details__pool_id' of table 'cloud.storage_pool_details'
        at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:186)
        at com.cloud.utils.db.ScriptRunner.runScript(ScriptRunner.java:88)
        at com.cloud.upgrade.DatabaseUpgradeChecker.runScript(DatabaseUpgradeChecker.java:240)
        ... 54 more
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions