Retry in 10 seconds to not make things worse

Part of #690
This commit is contained in:
Girish Ramakrishnan
2020-06-03 16:05:46 -07:00
parent f5076c87d4
commit 7a17695ad5

View File

@@ -76,8 +76,8 @@ function reconnect(callback) {
gConnectionPool.getConnection(function (error, connection) {
if (error) {
console.error('Unable to reestablish connection to database. Try again in a bit.', error.message);
return setTimeout(reconnect.bind(null, callback), 1000);
console.error('Unable to reestablish connection to database. Try again in 10 seconds.', error.message);
return setTimeout(reconnect.bind(null, callback), 10000);
}
connection.on('error', function (error) {
@@ -85,10 +85,10 @@ function reconnect(callback) {
// this function should be invoked only when we have no callbacks pending and we have a fatal error
assert(error.fatal, 'Non-fatal error on connection object');
console.error('Unhandled mysql connection error.', error);
console.error('Unhandled mysql connection error. Will reconnect in 10 seconds', error);
// This is most likely an issue an can cause double callbacks from reconnect()
setTimeout(reconnect.bind(null, callback), 1000);
setTimeout(reconnect.bind(null, callback), 10000);
});
gDefaultConnection = connection;