Tedious: Hung up in Final state

Created on 12 Jun 2017  ·  5Comments  ·  Source: tediousjs/tedious

To give a quick overview, I'm attempting to insert several hundred records asynchronously into our database using individual calls in the mssql npm. However, while using an older version 3.3.0 of mssql, I was sometimes not getting a callback from the npm. I updated mssql to 4.0.4 and am still not getting callbacks. I tracked it down to this npm.
After processPreLoginResponse it's getting sent to tls. Then it transitions to SentTLSSSLNegotiation. For some reason, after a few hundred records once it gets here, socketEnd is called. It then transitions to Final, the enter function is called, cleanupConnection is called (with no parameters), it clears the connection and request timers, closes the connection, socketClose is called and then it attempts to transition to Final again, and the enter function is not called, and it appears to just hang there indefinitely.
Any idea on why socketEnd is called in the first place or why it's never bubbled up to my code so I can handle it?

Most helpful comment

@landondavidson @jstephens7 https://github.com/tediousjs/tedious/pull/763 was merged and released as [email protected].

Please let us know if you're still encountering any issues. In the mean time, I'll close this issue. 🙇

All 5 comments

We are having this exact problem using an azure database. We can easily recreate the issue after about 4 hours of running an azure function on a 1 second timer. Is there anything we can do to help? This is a huge issue for us and we would love some kind of update on this issue.

Hey @landondavidson, sorry for the late response, do you mind sharing repo for this issue?
We had #574 that addressed intermittent ConnectionError in Azure DB, it was released in tedious v2.1.0, most of the connection pooling packages are using older version of tedious driver, can you verify if your dep is using latest driver?

@v-suhame, we are not seeing any ConnectionError. The socket just closes on us in the process of connecting. I just submitted a pull request with the fix we have put into production for the past two weeks. This is a website with pretty heavy load and the error have completely gone away with connection pooling retrying the connection after being reported.

@landondavidson @jstephens7 https://github.com/tediousjs/tedious/pull/763 was merged and released as [email protected].

Please let us know if you're still encountering any issues. In the mean time, I'll close this issue. 🙇

The fix from earlier is working for me, but I decided to run wireshark to try and see the network traffic leading to the error in the first place. I was able to reproduce the issue twice while running the trace.
I'm not sure of the significance of any portion of what I got back so I'll include what I noticed in common between the two times the error occurred.
Both times we had a PSH ACK and FIN ACK with a window size of 66560.
After that, both times we had a RST ACK.
Then it looks like it was starting the next TLS negotiation (client hello, server hello... encrypted handshake message)
After that, both times it started sending application data and we got a TLS "Encrypted alert" followed by ACKs and socket.end had been called (no further TLS/TCP traffic).

Was this page helpful?
0 / 5 - 0 ratings