mirror of https://github.com/apache/cloudstack.git
Fix ConfigurationVO load exception after schema change (#10485)
This commit is contained in:
parent
96728c5a17
commit
9fd2b90b80
|
|
@ -379,6 +379,9 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
|||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
if (upgrade.refreshPoolConnectionsAfterUpgrade()) {
|
||||
TransactionLegacy.refreshConnections(TransactionLegacy.CLOUD_DB);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,4 +38,8 @@ public interface DbUpgrade {
|
|||
void performDataMigration(Connection conn);
|
||||
|
||||
InputStream[] getCleanupScripts();
|
||||
|
||||
default boolean refreshPoolConnectionsAfterUpgrade() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import com.cloud.upgrade.SystemVmTemplateRegistration;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
|
@ -32,6 +28,10 @@ import java.util.Map;
|
|||
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
import com.cloud.upgrade.SystemVmTemplateRegistration;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
|
||||
private SystemVmTemplateRegistration systemVmTemplateRegistration;
|
||||
|
||||
|
|
@ -212,4 +212,9 @@ public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgr
|
|||
throw new CloudRuntimeException(String.format("Failed to migrate existing configuration scope values to bitmask due to: %s", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean refreshPoolConnectionsAfterUpgrade() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ public class ConfigDepotImplTest {
|
|||
String result = configDepotImpl.getConfigStringValue(key, ConfigKey.Scope.Global, null);
|
||||
Assert.assertEquals(value, result);
|
||||
Mockito.verify(_configDao, Mockito.times(configDBRetrieval)).findById(key);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -605,6 +605,15 @@ public class TransactionLegacy implements Closeable {
|
|||
return _conn;
|
||||
}
|
||||
|
||||
public static void refreshConnections(final short dbId) {
|
||||
if (dbId != CLOUD_DB) {
|
||||
return;
|
||||
}
|
||||
if (s_ds instanceof HikariDataSource) {
|
||||
((HikariDataSource)s_ds).getHikariPoolMXBean().softEvictConnections();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean takeOver(final String name, final boolean create) {
|
||||
if (_stack.size() != 0) {
|
||||
if (!create) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue