-
Notifications
You must be signed in to change notification settings - Fork 1.2k
check for active MSses before starting DB upgrade #12140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.20
Are you sure you want to change the base?
Changes from 5 commits
edcbbde
48af60a
46a6f7a
2135e1e
42414f4
6d9a6c5
0315005
335f144
e79dacb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -123,7 +123,10 @@ | |||||
| import com.cloud.utils.crypt.DBEncryptionUtil; | ||||||
| import com.cloud.utils.db.GlobalLock; | ||||||
| import com.cloud.utils.db.ScriptRunner; | ||||||
| import com.cloud.utils.db.Transaction; | ||||||
| import com.cloud.utils.db.TransactionCallback; | ||||||
| import com.cloud.utils.db.TransactionLegacy; | ||||||
| import com.cloud.utils.db.TransactionStatus; | ||||||
| import com.cloud.utils.exception.CloudRuntimeException; | ||||||
| import com.google.common.annotations.VisibleForTesting; | ||||||
|
|
||||||
|
|
@@ -448,39 +451,66 @@ public void check() { | |||||
| throw new CloudRuntimeException("Unable to acquire lock to check for database integrity."); | ||||||
| } | ||||||
|
|
||||||
| try { | ||||||
| initializeDatabaseEncryptors(); | ||||||
| if (isStandalone()) { | ||||||
| doUpgrades(lock); | ||||||
| } | ||||||
| } finally { | ||||||
| lock.releaseRef(); | ||||||
| } | ||||||
| } | ||||||
| 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; | ||||||
|
||||||
| return count == 0; | |
| return count <= 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one valid issue is that an MS performing an upgrade is not yet registered as UP. so this fix is better than what we have but certainly not watertight yet.
Uh oh!
There was an error while loading. Please reload this page.