Skip to content
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

MySql Connector throw an exception with a big concurrency volume #196

Closed
yukozh opened this issue Mar 17, 2017 · 15 comments
Closed

MySql Connector throw an exception with a big concurrency volume #196

yukozh opened this issue Mar 17, 2017 · 15 comments

Comments

@yukozh
Copy link

yukozh commented Mar 17, 2017

image

@yukozh yukozh changed the title MySql Connector throw an exception while a big concurrency volume MySql Connector throw an exception with a big concurrency volume Mar 17, 2017
@yukozh
Copy link
Author

yukozh commented Mar 17, 2017

I'm using mysql on azure(5.7) which provided by Microsoft China Cloud Innovation Center officially. Disabled reset connection.

@yukozh
Copy link
Author

yukozh commented Mar 17, 2017

Hi @bgrainger, @edwinsongmsft is the Principal Program Manager of Microsoft MySQL on Azure team. If you want to know what is the differences between normal MySQL and MySQL on Azure, you could communicate with him.

@edwinsongmsft
Copy link

edwinsongmsft commented Mar 17, 2017

Hi @bgrainger, as we did not support the auto reconnection, could u catch the exception and reconnect the database again? BR, Edwin

@bgrainger
Copy link
Member

bgrainger commented Mar 17, 2017

From the exception message, it seems like MySqlSession.TryPingAsync is being called on a session that is associated with a socket that already has an in-flight operation. I'm not exactly sure how to get into this situation; do you have more code that reproduces the problem that you can share?

@yukozh
Copy link
Author

yukozh commented Mar 17, 2017

it occurred in a big concurrency volume. There was no particular code.

@caleblloyd
Copy link
Contributor

caleblloyd commented Mar 20, 2017

Possible duplicate. This one uses MariaDB.

PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#221

@bgrainger
Copy link
Member

bgrainger commented Mar 20, 2017

"There is already an open DataReader associated with this Connection" (from the linked issue) could indicate incorrect use of the library. If that is the root cause, then perhaps it's possible that it could also cause the "An asynchronous socket operation is already in progress" exception?

If so, a good troubleshooting step might be to add explicit checks in public APIs of MySqlConnector to detect this situation and throw a more helpful exception earlier.

OTOH, there could be a bug in this library that's causing both exceptions. If we add that code to throw the new exception and it's not getting thrown, that would discount the "incorrect use" hypothesis.

@caleblloyd
Copy link
Contributor

caleblloyd commented Mar 20, 2017

Could this be coming from improperly disposed readers?

Do we force the reader to dispose when a connection is disposed? We might need to check the logic there. Since read buffering was added, we may need to add code to clear the read buffer as well.

@bgrainger
Copy link
Member

bgrainger commented Mar 20, 2017

Good call: MySqlConnection has HasActiveReader, but DoClose doesn't check it. (It will check if there's an active transaction and dispose (rollback) that.)

Disposing any active reader in MySqlConnection.DoClose may well work around this bug. (And once cancellation is actually correctly implemented, it may end up being more efficient to cancel the reader, rather than just read all its rows to the end.) And hopefully it wouldn't be too hard to reproduce this problem.

@caleblloyd
Copy link
Contributor

caleblloyd commented Mar 20, 2017

Since read buffering was added, we may need to add code to clear the read buffer as well.

Adding Reader Disposal to MySqlConnection.DoClose will take care of reading through anything that is buffered as well.

bgrainger added a commit that referenced this issue Mar 20, 2017
Dispose reader when disposing connection. Fixes #196
bgrainger added a commit to bgrainger/MySqlConnector that referenced this issue Mar 20, 2017
@bgrainger
Copy link
Member

bgrainger commented Mar 20, 2017

Should be fixed in 0.14.1.

@yukozh
Copy link
Author

yukozh commented Mar 22, 2017

@bgrainger There was another exception occurred with a big concurrency volume

image

@bgrainger
Copy link
Member

bgrainger commented Mar 22, 2017

This last exception is a duplicate of #162.

@yukozh
Copy link
Author

yukozh commented Mar 22, 2017

@bgrainger When will you fix #162? Our customer case was blocked by this.

@bgrainger
Copy link
Member

bgrainger commented Mar 23, 2017

@kagamine Is it possible that your customer uses cancellation in any way, i.e., calls Async overloads with something other than CancellationToken.None? My working hypothesis is that this is related to currently-unimplemented cancellation support #3 but so far I have been unable to obtain a consistent repro to prove/disprove that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants