Skip to content

Commit d0956d7

Browse files
abh1sardhslove
authored andcommitted
Fix ConfigurationVO load exception after schema change (apache#10485)
1 parent 0697ae2 commit d0956d7

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ private VersionVO executeUpgrade(DbUpgrade upgrade) {
377377
} finally {
378378
txn.close();
379379
}
380+
if (upgrade.refreshPoolConnectionsAfterUpgrade()) {
381+
TransactionLegacy.refreshConnections(TransactionLegacy.CLOUD_DB);
382+
}
380383
return version;
381384
}
382385

engine/schema/src/main/java/com/cloud/upgrade/dao/DbUpgrade.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ public interface DbUpgrade {
3838
void performDataMigration(Connection conn);
3939

4040
InputStream[] getCleanupScripts();
41+
42+
default boolean refreshPoolConnectionsAfterUpgrade() {
43+
return false;
44+
}
4145
}

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42100.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
// under the License.
1717
package com.cloud.upgrade.dao;
1818

19-
import com.cloud.upgrade.SystemVmTemplateRegistration;
20-
import com.cloud.utils.db.TransactionLegacy;
21-
import com.cloud.utils.exception.CloudRuntimeException;
22-
2319
import java.io.InputStream;
2420
import java.sql.Connection;
2521
import java.sql.PreparedStatement;
@@ -32,6 +28,10 @@
3228

3329
import org.apache.cloudstack.framework.config.ConfigKey;
3430

31+
import com.cloud.upgrade.SystemVmTemplateRegistration;
32+
import com.cloud.utils.db.TransactionLegacy;
33+
import com.cloud.utils.exception.CloudRuntimeException;
34+
3535
public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
3636
private SystemVmTemplateRegistration systemVmTemplateRegistration;
3737

@@ -212,4 +212,9 @@ protected void migrateExistingConfigurationScopeValues(Connection conn) {
212212
throw new CloudRuntimeException(String.format("Failed to migrate existing configuration scope values to bitmask due to: %s", e.getMessage()));
213213
}
214214
}
215+
216+
@Override
217+
public boolean refreshPoolConnectionsAfterUpgrade() {
218+
return true;
219+
}
215220
}

framework/config/src/test/java/org/apache/cloudstack/framework/config/impl/ConfigDepotImplTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ private void runTestGetConfigStringValueExpiry(long wait, int configDBRetrieval)
107107
String result = configDepotImpl.getConfigStringValue(key, ConfigKey.Scope.Global, null);
108108
Assert.assertEquals(value, result);
109109
Mockito.verify(_configDao, Mockito.times(configDBRetrieval)).findById(key);
110-
111110
}
112111

113112
@Test

framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,15 @@ public Connection getConnection() throws SQLException {
619619
return _conn;
620620
}
621621

622+
public static void refreshConnections(final short dbId) {
623+
if (dbId != CLOUD_DB) {
624+
return;
625+
}
626+
if (s_ds instanceof HikariDataSource) {
627+
((HikariDataSource)s_ds).getHikariPoolMXBean().softEvictConnections();
628+
}
629+
}
630+
622631
protected boolean takeOver(final String name, final boolean create) {
623632
if (_stack.size() != 0) {
624633
if (!create) {

0 commit comments

Comments
 (0)