Skip to content

Commit e1d5e30

Browse files
author
Athreya Permunda
committed
WL#12271 ATRT REPORT DATABASE CONNECTION FAILURE
Modify atrt such that a warning message with the connection failure message is issued whenever there is a failure in establishing a connection to MySQL instance. Also modify the error message appropriately to avoid repetition of connection failure messages. A warning message describing the connection failure is printed before printing each connection retry message to give a clear indication of why the connection retry is happening. Also, the error message printed no longer contains the error message but contains the host, port and socket for which connection is failing.
1 parent eb68087 commit e1d5e30

File tree

1 file changed

+7
-5
lines changed
  • storage/ndb/test/run-test

1 file changed

+7
-5
lines changed

storage/ndb/test/run-test/db.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -166,7 +166,8 @@ bool connect_mysqld(atrt_process& proc) {
166166
return false;
167167
}
168168

169-
for (size_t i = 0; i < 20; i++) {
169+
const int retries = 20;
170+
for (size_t i = 0; i < retries; i++) {
170171
if (port) {
171172
mysql_protocol_type val = MYSQL_PROTOCOL_TCP;
172173
mysql_options(&proc.m_mysql, MYSQL_OPT_PROTOCOL, &val);
@@ -176,14 +177,15 @@ bool connect_mysqld(atrt_process& proc) {
176177
0)) {
177178
return true;
178179
}
180+
g_logger.warning("Failed to connect: %s", mysql_error(&proc.m_mysql));
179181
g_logger.info("Retrying connect to %s:%u 3s",
180182
proc.m_host->m_hostname.c_str(), atoi(port));
181183
NdbSleep_SecSleep(3);
182184
}
183185

184-
g_logger.error("Failed to connect to mysqld err: >%s< >%s:%u:%s<",
185-
mysql_error(&proc.m_mysql), proc.m_host->m_hostname.c_str(),
186-
port ? atoi(port) : 0, socket ? socket : "<null>");
186+
g_logger.error("Giving up attempt to connect to Host: %s; Port: %u;"
187+
"Socket: %s after %d retries", proc.m_host->m_hostname.c_str(),
188+
port ? atoi(port) : 0, socket ? socket : "<null>",retries);
187189
return false;
188190
}
189191

0 commit comments

Comments
 (0)