DaanHoogland commented on code in PR #12140:
URL: https://github.com/apache/cloudstack/pull/12140#discussion_r2581463073


##########
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:
   one valid issue is that an MS performing an upgrade is not yet regsitered as 
UP. so this fix is better than what we have but certainly not watertight yet.



-- 
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]

Reply via email to