microfisher / NETCore-Snowflake-Framework

雪花框架:基于.NET Core + Mysql + Redis + RabbitMQ 设计的高性能多层架构,涵盖了仓储设计模式、全局日志、JWT授权认证、Swagger API管理、请求时间统计等功能,Docker配置文件、服务安装文件等。
64 stars 22 forks source link

Use MySqlConnector for async I/O #2

Open bgrainger opened 3 years ago

bgrainger commented 3 years ago

The Repository code uses ExecuteScalarAsync. It's a long-standing bug in MySql.Data (bug 70111) that async I/O is not implemented correctly; thus all these methods will actually run synchronously. (See also here and here on Stack Overflow.)

To fix this, you could switch to https://github.com/mysql-net/MySqlConnector, an OSS replacement for MySql.Data that supports true asynchronous I/O; it also has full .NET Standard/.NET Core support.

If you're interested in this, I'd be happy to open a PR.

microfisher commented 3 years ago

thanks! but we all use Mysql.Data for a long time, it looks alright, are you sure about this?

bgrainger commented 3 years ago

I know for a fact that all the ExecuteNonQueryAsync, ExecuteReaderAsync etc. methods in MySql.Data don't actually execute asynchronously. (For example, see the bug report I linked above, and notice that there is no implementation of those methods in the repo: https://github.com/mysql/mysql-connector-net/search?q=ExecuteNonQueryAsync.)

If using actual async I/O is important to this project, then you'll need to change MySQL .NET libraries.

microfisher commented 3 years ago

thanks a lot! i'll fix it.