You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sh...@apache.org on 2022/09/13 08:42:59 UTC

[cloudstack] branch 4.16 updated: Reset unusable db connections (#6725)

This is an automated email from the ASF dual-hosted git repository.

shwstppr pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.16 by this push:
     new 77df050160 Reset unusable db connections (#6725)
77df050160 is described below

commit 77df050160d6a5343aab97571bf891e51b4b1201
Author: mrog <47...@users.noreply.github.com>
AuthorDate: Tue Sep 13 02:42:53 2022 -0600

    Reset unusable db connections (#6725)
    
    When the management service detects a broken database connection, it didn't do anything about it. It already has code to reset the connection, but that doesn't get used. This change causes the connection to be reset after it's found to be unusable.
    
    Fixes #6724 (see issue for repro steps)
---
 .../db/src/main/java/com/cloud/utils/db/ConnectionConcierge.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/framework/db/src/main/java/com/cloud/utils/db/ConnectionConcierge.java b/framework/db/src/main/java/com/cloud/utils/db/ConnectionConcierge.java
index a1c473d5ff..2ae0de90f2 100644
--- a/framework/db/src/main/java/com/cloud/utils/db/ConnectionConcierge.java
+++ b/framework/db/src/main/java/com/cloud/utils/db/ConnectionConcierge.java
@@ -174,7 +174,7 @@ public class ConnectionConcierge {
 
             Connection conn = TransactionLegacy.getStandaloneConnection();
             if (conn == null) {
-                return "Unable to get anotehr db connection";
+                return "Unable to get another db connection";
             }
 
             concierge.reset(conn);
@@ -198,9 +198,13 @@ public class ConnectionConcierge {
                 protected void runInContext() {
                     s_logger.trace("connection concierge keep alive task");
                     for (Map.Entry<String, ConnectionConcierge> entry : _conns.entrySet()) {
+                        String name = entry.getKey();
                         ConnectionConcierge concierge = entry.getValue();
                         if (concierge.keepAlive()) {
-                            testValidity(entry.getKey(), entry.getValue().conn());
+                            if (testValidity(name, concierge.conn()) != null) {
+                                s_logger.info("Resetting DB connection " + name);
+                                resetConnection(name);
+                            }
                         }
                     }
                 }