-
Notifications
You must be signed in to change notification settings - Fork 341
EndOfStreamException in ResetConnectionAsync with Amazon Aurora #208
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
Comments
What version of MySQL Server are you using? What is the OS of the client and server? What is your connection string (without the password)? |
MySQL Server Server OS Connection String |
Given the IL offset in the exception call stack, I suspect this line is throwing the exception. I haven't been able to reproduce with MySQL Server 5.6.29 locally (with 100 concurrent readers and one inserter/deleter). Given the server hostname, I assume your server is Amazon RDS? It's possible this could be an RDS-specific bug (similar to #169 for Azure). I will need to set up a RDS instance for testing to confirm this. Finally, I see |
That's correct, server is on Amazon RDS. We are using EF Core (Pomelo) for MySQL with the latest version of MySqlConnector (0.15.1) |
Is it Amazon Aurora, MariaDB, or MySQL? (All of these speak the MySQL protocol but could have (very) different backends.) |
Aurora |
I set up an |
Hmm strange... |
I have the same problem with RDS Aurora (Amazon). All latest versions. |
Are you using EF Core (Pomelo), or just MySqlConnector? Can you describe your scenario (that might help us develop a repro) or provide a small code sample that demonstrates it? |
Short version: Putting a try/catch around Long version: I've been battling this problem since switching to Aurora from SQL Server, and it's almost been frustrating enough to switch back. We've experienced it on both read and write queries, and when it happens it will affect connections from multiple app servers in our farm, for several seconds. I am all but certain it is a problem with Aurora. It looks like after Aurora challenges the client for authentication and the client responds, it will abruptly close the connection. It is reminiscent of #169 but instead of "Access denied for user", it is sending an RST to close the connection. Without any "on-demand" way to reproduce it I'm not sure how to go about confirming it’s an Aurora bug. Cloning our database and running various stress tests got me nowhere, but during normal usage we experience this problem several times per day. We have ~50 connections and ~15% utilization on an r3.large instance. We do have frequent connections due to setting Connection Lifetime to 5 seconds, so that failover to the writable primary instance happens more quickly. In my testing, the default Connection Lifetime setting of 0 (forever), as well as One interesting thing is that I did not experience this problem in MySqlConnector if TLS was disabled via MySql.Data experiences this regardless of TLS being on or off, which is actually what let me to start using MySqlConnector in the first place. There are some issues on MySQL's bug tracker about similar problems. In the first one the user is using RDS but it's not clear if it's Aurora or not: MySQL Bugs: #76597: Reading from stream failed The problem is narrowed down to a Stream.Read returning 0 but doesn't get any further than that. Another issue was opened: MySQL Bugs: #86056: MySqlException (0x80004005): Reading from the stream has failed. where @bgrainger rightly points out that the client code is doing the correct thing - if you read 0 bytes you don't have much choice but to throw, close the connection, or both. Here are the exceptions I’ve observed from different clients / configurations: MySql.Data, TLS enabled:
MySql.Data, TLS disabled via Ssl Mode=None:
MySqlConnector, TLS enabled (basically identical to what @sherloqholmes provided):
As I was reviewing logs yesterday, I realized that every single
Walking through the
I initially thought this situation was triggered by trying to reuse the challenge from the initial handshake, but I don't believe the MySql.Data client does that and it appears to affect both MySql.Data and MySqlConnector. Is this the right way to fix this (working around a possible server bug)? I don't know, but in the end it makes my application work better and I don't see much downside to covering up a failed connection reset / authentication and returning a new session. Curious to hear from anyone else who has experienced this problem. |
…ssion (works around mysql-net#208)
Try/catch ResetConnectionAsync (works around #208).
@bnabholz Thanks for the detailed investigation and patch! Gracefully recovering from failure to reset the connection (then opening a new connection) sounds like the right approach to me. It's obviously less-than-ideal that it takes a few network roundtrips for the reset connection to eventually fail, but there's not much we can do about that. It does sound like an Aurora bug (from your description) but if it only happens with TLS it would be difficult to get a packet capture to "prove" it. |
This was fixed in 0.26.4. |
Uh oh!
There was an error while loading. Please reload this page.
When running a lot of queries (SELECT, INSERT, UPDATE, DELETE) at the same moment on the same server we are seeing an increasing amount of EndOfStreamExceptions.
We were able to reproduce this issue on a server with ±100 concurrent users.
What happend
Stacktrace
The text was updated successfully, but these errors were encountered: