Pomelo.EntityFrameworkCore.MySql
Pomelo.EntityFrameworkCore.MySql copied to clipboard
ServerVersion.AutoDetect hangs when connecting to RDS Proxy
Steps to reproduce
Trying to connect to RDS Proxy for MySql while using ServerVersion.AutoDetect(rdsProxyConnectionString)
.
The issue
When using AutoDetect for server version, app hangs indefinetly when it tries to connect to the database proxy. No exceptions are thrown and no errors are logged.
If you replace ServerVersion.AutoDetect(rdsProxyConnectionString)
for example with ServerVersion.Parse("8.0.28")
app connects to the proxy without any problems.
Further technical details
MySQL version: 8.0.28 Operating system: Windows / Linux Pomelo.EntityFrameworkCore.MySql version: 6.0.2 Microsoft.AspNetCore.App version: 6.0.4
Assuming that you're using Amazon RDS for MySQL as the backend database server and not Amazon Aurora.
The AutoDetect code is very simple, it connects to the instance using MySqlConnector and parses the value from the ServerVersion property.
https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/00b4353d95a342bed33f8a15b63f9afb02933a39/src/EFCore.MySql/Infrastructure/ServerVersion.cs#L71-L77
Try replicating that in a test console app using MySqlConnector 2.1.2 (used by Pomelo 6.0.2) and configure Logging set to trace log level.
I ran into something similar with connecting to Aurora directly. Try adding ;Pipelining=False
to your connection string and see if that helps.
I'm running into this issue as well on an MySQL Aurora 5.7 cluster. When I have the Server value of the connection string pointed to an AWS Route53 private zone the first connection works but the next request just hangs as described above. Pointing to the public writer and reader CNAMEs provided by AWS for the cluster are working without issue.
The implementation is using the AutoDetect setting and I've also tried setting it explicitly to 5.7.
Runtime: .net 6 Pomelo: 6.0.1 MySqlConnector 2.1.2 EFCore.Relational 6.0.1
Setting the pipelining to false seems to correct the issue however it doesn't make any sense that it the failure is tied to just a private CNAME record. According to this https://mysqlconnector.net/troubleshooting/aurora-freeze/ it should always fail.
Has a correction been done in version 7.x to handle the issue?