DaanHoogland commented on code in PR #12140:
URL: https://github.com/apache/cloudstack/pull/12140#discussion_r2607009943
##########
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java:
##########
@@ -448,39 +450,76 @@ public void check() {
throw new CloudRuntimeException("Unable to acquire lock to
check for database integrity.");
}
- try {
- initializeDatabaseEncryptors();
-
- final CloudStackVersion dbVersion =
CloudStackVersion.parse(_dao.getCurrentVersion());
- final String currentVersionValue =
this.getClass().getPackage().getImplementationVersion();
+ doUpgrades(lock);
+ } finally {
+ lock.releaseRef();
+ }
+ }
- if (StringUtils.isBlank(currentVersionValue)) {
- return;
+ private boolean isStandalone() throws CloudRuntimeException {
+ return Transaction.execute(new TransactionCallback<>() {
+ @Override
+ public Boolean doInTransaction(TransactionStatus status) {
+ String sql = "SELECT COUNT(*) FROM `cloud`.`mshost` WHERE
`state` = 'UP'";
+ try (Connection conn =
TransactionLegacy.getStandaloneConnection();
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery()) {
+ if (rs.next()) {
+ int count = rs.getInt(1);
+ return count == 0;
Review Comment:
You are right however we cannot defend against what we do not know. I think
any MS being Up will be registered as Up, maybe not the other way around. In
which case we will stop and a manual DB action will have to be taken to
remedie. Is there any reason to doubt the added value of this check though,
@weizhouapache ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]