Skip to content

Commit 77df050

Browse files
authored
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)
1 parent 4ed1be8 commit 77df050

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public String resetConnection(String name) {
174174

175175
Connection conn = TransactionLegacy.getStandaloneConnection();
176176
if (conn == null) {
177-
return "Unable to get anotehr db connection";
177+
return "Unable to get another db connection";
178178
}
179179

180180
concierge.reset(conn);
@@ -198,9 +198,13 @@ public String resetKeepAliveTask(int seconds) {
198198
protected void runInContext() {
199199
s_logger.trace("connection concierge keep alive task");
200200
for (Map.Entry<String, ConnectionConcierge> entry : _conns.entrySet()) {
201+
String name = entry.getKey();
201202
ConnectionConcierge concierge = entry.getValue();
202203
if (concierge.keepAlive()) {
203-
testValidity(entry.getKey(), entry.getValue().conn());
204+
if (testValidity(name, concierge.conn()) != null) {
205+
s_logger.info("Resetting DB connection " + name);
206+
resetConnection(name);
207+
}
204208
}
205209
}
206210
}

0 commit comments

Comments
 (0)