-
Notifications
You must be signed in to change notification settings - Fork 183
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
Connection to database hangs after Error: read ETIMEDOUT #456
Comments
Thanks for the detailed report on the issue, @bmaupin! I've read through the other issue, and cross-checked with the source code here; It does seem that this package doesn't properly handle connection errors after the initial connection:
Unfortunately I'm not sure why this is the case; This could be due to a retry mechanism either in the mysql package or the transport protocol.
When starting up, the connector does check for any errors, but does not distinguish between fatal and non-fatal: loopback-connector-mysql/lib/mysql.js Lines 90 to 105 in 76e09ea
Though this check only happens during app startup; Afterwards, it does not seem that there's any re-connection logic in either the connector nor the Juggler ORM. When loopback-connector-mysql/lib/mysql.js Lines 186 to 194 in 76e09ea
Which should throw an error; This should cause the application to continue or crash (depending on several factors), but it shouldn't hang. NB: The use of I've not tested for a potential solution, but I suspect the issue is with this line: loopback-connector-mysql/lib/mysql.js Line 250 in 76e09ea
This seems to be where all query logic converges at, and there's no check for fatal errors. Unfortunately, why is hangs is still a mystery. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We're using loopback-connector-mysql v6.0.2 and normally any time there's a database issue, the application automatically reconnects to the database without any intervention on our part.
However, we recently ran into an issue where this did not happen. Even though the database was running, the application would not reconnect to the database until I restarted it.
These were the errors in the log:
(the last error is repeated, I'm guessing for each connection in the pool).
In searching online for similar errors, using a pool seems to be the solution for this sort of problem. Of course, this connector is already using a pool, so I'm not sure what options I have to fix this. Unfortunately despite my best efforts I've been unable to reproduce that exact error and so I can't provide a way to reproduce it at this time.
My understanding is that any time a connection encounters an error, it's supposed to be released from the pool to make room for new connections. Why didn't that happen?
According to mysqljs/mysql#2522 (comment), I wonder if it could be a bug in this library since we aren't calling any of the underlying methods directly:
I don't see a single mention of
fatal
in this library. Maybe some extra logic needs to be added to handle fatal errors? Even crashing the application would be preferable to it hanging, because at least then we could know to restart it.Thanks!
The text was updated successfully, but these errors were encountered: